From 78e6b19d4678a9d641c4afa4ca800288cfa0a9d5 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sat, 15 Apr 2023 03:01:57 +0000 Subject: CTAN sync 202304150301 --- graphics/pgf/contrib/quickreaction/README.txt | 14 + .../pgf/contrib/quickreaction/quickreaction.pdf | Bin 0 -> 249110 bytes .../pgf/contrib/quickreaction/quickreaction.sty | 99 ++++++ .../pgf/contrib/quickreaction/quickreaction.tex | 343 +++++++++++++++++++++ graphics/pstricks/contrib/pst-func/Changes | 2 + .../pstricks/contrib/pst-func/doc/pst-func-doc.pdf | Bin 4065407 -> 4109072 bytes .../pstricks/contrib/pst-func/doc/pst-func-doc.tex | 110 ++++++- .../pstricks/contrib/pst-func/dvips/pst-func.pro | 56 +++- .../pstricks/contrib/pst-func/latex/pst-func.sty | 6 +- .../pstricks/contrib/pst-func/tex/pst-func.tex | 60 +++- 10 files changed, 667 insertions(+), 23 deletions(-) create mode 100644 graphics/pgf/contrib/quickreaction/README.txt create mode 100644 graphics/pgf/contrib/quickreaction/quickreaction.pdf create mode 100644 graphics/pgf/contrib/quickreaction/quickreaction.sty create mode 100644 graphics/pgf/contrib/quickreaction/quickreaction.tex (limited to 'graphics') diff --git a/graphics/pgf/contrib/quickreaction/README.txt b/graphics/pgf/contrib/quickreaction/README.txt new file mode 100644 index 0000000000..1433292d07 --- /dev/null +++ b/graphics/pgf/contrib/quickreaction/README.txt @@ -0,0 +1,14 @@ +quickreaction package + v 1.02 + 2023/04/11 + +Maintainer: Lambertini Francesco +E-mail : kekko.francy@gmail.com +Licence : Released under the LaTeX Project Public License v1.3c or + later, see http://www.latex-project.org/lppl.txt + +---------------------------------------------------------------------- + +This package provides the quickreaction environment and the \quickarrow +command to simplify the typesetting of chemical reactions. +It is based on the TikZ package. diff --git a/graphics/pgf/contrib/quickreaction/quickreaction.pdf b/graphics/pgf/contrib/quickreaction/quickreaction.pdf new file mode 100644 index 0000000000..47bed6e64f Binary files /dev/null and b/graphics/pgf/contrib/quickreaction/quickreaction.pdf differ diff --git a/graphics/pgf/contrib/quickreaction/quickreaction.sty b/graphics/pgf/contrib/quickreaction/quickreaction.sty new file mode 100644 index 0000000000..9aafdc199b --- /dev/null +++ b/graphics/pgf/contrib/quickreaction/quickreaction.sty @@ -0,0 +1,99 @@ + %% Copyright 2023 Lambertini Francesco + % + % This work may be distributed and/or modified under the + % conditions of the LaTeX Project Public License, either version 1.3 + % of this license or any later version. + % The latest version of this license is in + % http://www.latex-project.org/lppl.txt + % and version 1.3 or later is part of all distributions of LaTeX + % version 2023/04/11 or later. + % + % This work has the LPPL maintenance status `maintained'. + % + % The Current Maintainer of this work is Lambertini Francesco. + % + % This work consists of the files quickreaction.sty, quickreaction.tex and quickreaction.pdf. +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{quickreaction}[2023/04/11] + +\RequirePackage{tikz} +\RequirePackage{xparse} + +\usetikzlibrary{matrix} +\usetikzlibrary{positioning} + +\DeclareOption{iupac}{% +\renewcommand{\printatom}[1]{% +\fontsize{8pt}{10pt}\selectfont{\ensuremath{\mathsf{#1}}}} +\setchemfig{ +cram rectangle=false, +cram width=2.5pt, +cram dash width=0.5pt, +cram dash sep=1.5pt, +atom sep=16pt, +bond offset=1pt, +double bond sep=2pt, +bond join = true, +bond style={line width=0.5pt} +} +} +\ProcessOptions\relax + +\makeatletter +\newcommand{\settomaxwidth}[1]{\saltyarrow@settomax{\wd}{#1}} +\newcommand{\saltyarrow@settomax}[3]{% +\newdimen\pippo +\pippo=1cm + #2\pippo + \@for\next:=#3\do{% + \sbox\z@{\next}% + \ifdim#1\z@>#2% + #2=#1\z@ + \fi}% +} +\makeatother + +\newlength{\saltyarrowmax} + +\newlength{\fixrow} + +\NewDocumentEnvironment{quickreaction}{O{} O{} b}{% +% +\newbox\fixa +\newbox\fixb +\savebox{\fixa}{#1} +\savebox{\fixb}{#2} +\def\a{\the\dp\fixa} +\def\aa{\the\ht\fixa} +\def\b{\the\dp\fixb} +\def\bb{\the\ht\fixb} +\pgfmathsetlength{\fixrow}{(\a+\aa-\b-\bb)/2)} +% +\newcommand{\reactionbody}{#3} + \begin{tikzpicture}[baseline=(current bounding box.center)] + \matrix (reaction) [% + ampersand replacement=\&, + matrix of nodes, + column sep=\pgflinewidth, + row sep=\pgflinewidth, + nodes={anchor=center}, + ] {\reactionbody}; + \end{tikzpicture}% + }{} + +%\AddToHook{env/quickreaction/begin}{\catcode`\&\active} + +\NewDocumentCommand{\quickarrow}{O{} O{}}{% +\newcommand{\argone}{#1}% +\newcommand{\argtwo}{#2}% +\settomaxwidth{\saltyarrowmax}{\argone, \argtwo}% +\begin{tikzpicture} + \draw [-stealth] (-0.5,0) -- node[anchor=center] (X) {} (\the\saltyarrowmax,0); + \node (A) [above= 0pt of X] {\argone}; + \node (B) [below= 0pt of X] {\argtwo}; + \phantom{ \node (AA) [below= 0pt of X] {\argone};} + \phantom{ \node (BB) [above= 0pt of X] {\argtwo};} +\end{tikzpicture} +} + + diff --git a/graphics/pgf/contrib/quickreaction/quickreaction.tex b/graphics/pgf/contrib/quickreaction/quickreaction.tex new file mode 100644 index 0000000000..1b5770b6cc --- /dev/null +++ b/graphics/pgf/contrib/quickreaction/quickreaction.tex @@ -0,0 +1,343 @@ + %% Copyright 2023 Lambertini Francesco + % + % This work may be distributed and/or modified under the + % conditions of the LaTeX Project Public License, either version 1.3 + % of this license or any later version. + % The latest version of this license is in + % http://www.latex-project.org/lppl.txt + % and version 1.3 or later is part of all distributions of LaTeX + % version 2023/04/11 or later. + % + % This work has the LPPL maintenance status `maintained'. + % + % The Current Maintainer of this work is Lambertini Francesco. + % + % This work consists of the files quickreaction.sty, quickreaction.tex and quickreaction.pdf. +\documentclass{scrarticle} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage[english]{babel} +\usepackage{microtype} +\usepackage{siunitx} + +\usepackage{amsmath} +\usepackage{amssymb} + +\usepackage[dvipsnames ]{xcolor} +\definecolor{unipd}{RGB}{176, 0, 0} + +\usepackage{xparse} +\usepackage{tikz} +\usepackage{chemfig} +\usepackage{mol2chemfig} + +\usepackage[iupac]{quickreaction} + + +%molecules +%C1=COC=C1 +\newcommand{\furan}{\chemfig{-[:180,,,,dbl={73}{73}]-[:252]O-[:324]-[:36,,,,dbl={73}{73}](-[:108])}} +%CC(=O)[Cl] +\newcommand{\acetylclorhyde}{\chemfig{-[:90](=[:150]O)-[:30]Cl}} +%CC(=O)C1=CC=CO1 +\newcommand{\acetylfuran}{\chemfig{-[:294](=[:234]O)-[:354]-[:300,,,,dbl={73}{73}]-[:12]-[:84,,,,dbl={73}{73}]-[:156]O(-[:228])}} +%C(CC(=O)OCC)(=O)OCC +\newcommand{\diethylmalonate}{\chemfig{-[:30]-[:-30]O-[:30](=[:90]O)-[:-30]-[:30](=[:90]O)-[:-30]O-[:30]-[:-30]}} +%4-chlorobenzaldehyde +\newcommand{\chlorobenzaldehyde}{\chemfig{O=[:300](-[:-120]H)--[:300,,,,dlh]--[:60,,,,dlh](-Cl)-[:120]-[:180,,,,dlh](-[:240])}} +%CC(=O)CC(C1=CC=C(C=C1)Cl)O +\newcommand{\clhydroxybutanone}{\chemfig{-[:300](=[:240]O)--[:60](<:[:120,,,2]HO)--[:300,,,,dlh]--[:60,,,,dlh](-Cl)-[:120]-[:180,,,,dlh](-[:240])}} +%CC(=O)C +\newcommand{\acetone}{\chemfig{-[:30](=[:90]O)-[:-30]}} +%C1C[C@H](NC1)C(=O)O +\newcommand{\Lproline}{\chemfig{O=[:132](-[:72,,,1]OH)>[:192]-[:138]-[:210]-[:282]-[:354]\mcfbelow{N}{H}(-[:66])}} + + +\usepackage{listings} +\lstset{% +columns=fullflexible , +basicstyle=\small\ttfamily, +language={[LaTeX]TeX}, +breaklines=true, +frame=single, +framexleftmargin=3mm, +xleftmargin=3mm, +prebreak = {\hbox{\textcolor{gray}{\%}}}, +backgroundcolor=\color{blue!5}, +rulecolor=\color{black}, +morekeywords={printatom, setchemfig, chemfig, arrowlength, quickarrow, fixrow}, +%keywordstyle=[2]{\color{gray}}, +%morekeywords=[2]{tikz, xparse, chemfig, quickreaction}, +moredelim=[is][\ttfamily]{|}{|}, +literate=*{\&}{{\textcolor{red}{\&}}}{1}, +keywordstyle=\color[rgb]{0,0,1}, +commentstyle=\color[RGB]{128,128,128}, +stringstyle=\color[rgb]{0.627,0.126,0.941} +} + +\usepackage{hyperref} +\hypersetup{ +colorlinks=true, +urlcolor=ForestGreen, +linkcolor=black, +} + + +\begin{document} + +\begin{center} +\textbf{\Huge quickreaction} + +\vspace{0.5cm} + +v1.02 \hspace{1cm} 2023/04/11 + +\vspace{0.5cm} + +Simple and fast way to typeset chemical reactions + + \vspace{0.5cm} + +Lambertini Francesco + +\vspace{0.5cm} + +\href{mailto: kekko.francy@gmail.com}{kekko.francy@gmail.com} +\end{center} + + +\tableofcontents + +\section{Licence} +This work may be distributed and/or modified under the conditions of the \LaTeX~Project Public License, version 1.3c or later. The latest version of this license is at \url{https://www.latex-project.org/lppl.txt}. + +\section{Requirements} +\lstinline{quickreaction} needs the packages \href{https://ctan.org/pkg/xparse}{\ttfamily xparse} and \href{https://ctan.org/pkg/tikz-page}{\ttfamily tikz}. It loads tiks libraries \href{https://tikz.dev/library-matrix}{\ttfamily matrix} and \href{https://tikz.dev/tikz-shapes#sec-17.5}{\ttfamily positioning}. + +\section{Motivations} +The aim of this package is to provide a simple and fast way to typeset elementary chemical reactions. There are already some packages that provide many and more sophisticated ways to draw all kinds of schemes, but all of them require a lot of effort. When you try to typeset a reaction, problems arise when it is time to align all reactants and, most of all, to align their names. For simple compounds, it is not so difficult to get good results, but for larger molecules, you have to spend a lot of time in order to do it. In addition, there are many commands and environments that provide various types of arrows to use in reaction schemes, but none of them have all the necessary functions: an arrow must extend with the text, support arguments of any type, and have the ability to use parboxes for any numbered indications, which are common in chemistry. + +This package is nothing else than a bunch of macros I used to create reactions in the fastest way when an incoming project is imminent, but I decided to publish it in order to help everyone who gets stuck at first and decides to switch to other programs which, even if they can be powerful reaction setters, often do not match the style of the document with different fonts, graphical styles and blurred images that, when inserted, irremediably compromise the style of the document. A chemist-proof way to create reactions may help to initiate newbies and expand the use of \LaTeX \ in chemistry. + +\section{Options} + +Using \href{https://www.ctan.org/pkg/chemfig}{\ttfamily chemfig} as a chemical structure drawer, the option {\ttfamily iupac} sets the style of bonds following what I have inferred and summarized from the \href{https://iupac.qmul.ac.uk/drawing/drawing.html}{\ttfamily IUPAC reccomendations}. Without this option, the chemfig style will be the standard one. In case you want your own configuration, simply copy and paste the code below in your preamble to change it as you like. You can find the explanation of the terms and more options in the \href{https://ctan.mirror.garr.it/mirrors/ctan/macros/generic/chemfig/chemfig-en.pdf}{\ttfamily chemfig manual}. + +\begin{lstlisting} +\renewcommand{\printatom}[1]{% +\fontsize{8pt}{10pt}\selectfont{\ensuremath{\mathsf{#1}}}} +\setchemfig{ +cram rectangle=false, +cram width=2.5pt, +cram dash width=0.5pt, +cram dash sep=1.5pt, +atom sep=16pt, +bond offset=1pt, +double bond sep=2pt, +bond join = true, +bond style={line width=0.5pt} +} +\end{lstlisting} + +\section{Basic Usage} +This package provides the \lstinline{quickreaction} environment and the command \lstinline{\quickarrow}. It is based on the \href{https://tikz.dev/tikz-matrices}{\ttfamily TikZ matrix of nodes} and aligns all the reactants and products at the center of the TikZ box in which they are contained. For most cases, it is a sufficient setting to get good results, but to achieve perfection, one can use many other packages, for example, \href{https://www.ctan.org/pkg/chemfig}{\ttfamily chemfig} itself or \href{https://www.ctan.org/pkg/mychemistry}{\ttfamily mychemistry}. An example is worth more than a thousand words: + +\begin{lstlisting} +%Preamble +|\usepackage{xparse} +\usepackage{tikz} +\usepackage{chemfig} +\usepackage[iupac]{quickreaction}| +%Document +\begin{quickreaction} +\chemfig{[:30]-(-[:90])=_[:-30]--[:-30]} \& \quickarrow[\chemfig{O_3}][\chemfig{DMS}] \& \chemfig{[:30]-(-[:90])=_[:-30]O} \& + \& \chemfig{O=_[:-30]-[:30]-[:-30]} \\ +2-methyl-2-pentene \& \& |acetone| \& \& 1-propanone \\ +\end{quickreaction} +\end{lstlisting} + +\begin{center} +\begin{quickreaction} +\chemfig{[:30]-(-[:90])*6(=-(-[:-30]))} \& \quickarrow[\chemfig{O_3}][\chemfig{DMS}] \& \chemfig{-[:30](=[:90]O)-[:-30]} \& + \& \chemfig{H-[:30](=[:90]O)-[:-30]-[:30]} \\ +2-methyl-2-pentene \& \& acetone \& \& 1-propanone \\ +\end{quickreaction} +\end{center} + +The structure of the reaction simply follows the TikZ matrix syntax: the separator between cells is \lstinline{\&} and for rows is \lstinline{\\}. I changed the cell separator from the standard \lstinline{&} to \lstinline{\&} to avoid beamer issues. + +The \lstinline{\quickarrow} command has two optional arguments: one for the label above and one for the label below. The minimum arrow length is set at \qty{1}{\centi \m}. +\begin{center} +\lstinline{\quickarrow[label above][label below]} +\end{center} + + +\section{Advises for Ultra-fast Reaction Typeset} + +As far as I know, with the introduction of this package, the combo \href{https://www.ctan.org/pkg/mol2chemfig}{\ttfamily mol2chemfig} and \lstinline{quickreaction} can lead to the fastest way to draw chemical reactions with \LaTeX. \href{https://www.ctan.org/pkg/mol2chemfig}{\ttfamily mol2chemfig} is a Python program that generates the chemfig code just from the SMILES (Simplified Molecular Input Line Entry System), which can be obtained from any graphical software for drawing molecules or from any online database. The unofficial version available for Python3 is downloadable at \url{https://pypi.org/project/mol2chemfigPy3/}. To obtain the chemfig string, I usually use the command +\begin{center} +\lstinline{|mol2chemfig -zwf -i direct "SMILES"|} +\end{center} + +Once obtained, the chemfig code can be slapped into the \lstinline{quickreaction} environment without any knowledge of what you are doing, but obtaining almost instantly the desired result. + +\section{Examples} +Chemfig string can be very long so in the next examples I will create a macro for every compound with a \lstinline{\newcommand} in the preamble in order to keep the environment clean and to focus on the examples aspects. + +\subsection{Labels Aligment} +It is common in chemistry to specify the order of multiple separate steps in a reaction. + +\begin{lstlisting} +%Preamble +|\usepackage{xparse} +\usepackage{tikz} +\usepackage{chemfig} +\usepackage{mol2chemfig} +\usepackage[iupac]{quickreaction}| + +%C1=COC=C1 +\newcommand{\furan}{\chemfig{-[:180,,,,dbl={73}{73}]-[:252]O-[:324]-[:36,,,,dbl={73}{73}](-[:108])}} +%CC(=O)[Cl] +\newcommand{\acetylclorhyde}{\chemfig{-[:90](=[:150]O)-[:30]Cl}} +%CC(=O)C1=CC=CO1 +\newcommand{\acetylfuran}{\chemfig{-[:294](=[:234]O)-[:354]-[:300,,,,dbl={73}{73}]-[:12]-[:84,,,,dbl={73}{73}]-[:156]O(-[:228])}} + +%Document +\begin{quickreaction} +\furan \& + \& \acetylclorhyde \& \quickarrow[1) \chemfig{BF_3}][2)\chemfig{H_2O}] \& \acetylfuran \\ +furan \& \& acetylclorhyde \& \& 2-acetylfuran \\ +\end{quickreaction} +\end{lstlisting} + +\begin{center} +\begin{quickreaction} +\furan \& + \& \acetylclorhyde \& \quickarrow[1) \chemfig{BF_3}][2) \chemfig{H_2O}] \& \acetylfuran \\ +furan \& \& acetylclorhyde \& \& 2-acetylfuran \\ +\end{quickreaction} +\end{center} + +Usually, when there are no steps, arrow labels above and below are centered but when there are multiple steps labels are left aligned, as in a list. In the above example labels are centered by default and the numbers result not correctly aligned. The use of a properly sized \lstinline{\parbox} solves the problem: + +\begin{lstlisting} +\begin{quickreaction} +\furan \& + \& \acetylclorhyde \& \quickarrow[\parbox{1.2cm}{1) \chemfig{BF_3}}][\parbox{1.2cm}{2) \chemfig{H_2O}}] \& \acetylfuran \\ +|furan| \& \& |acetylclorhyde| \& \& |2-acetylfuran| \\ +\end{quickreaction} +\end{lstlisting} + +\begin{center} +\begin{quickreaction} +\furan \& + \& \acetylclorhyde \& \quickarrow[\parbox{1.2cm}{1) \chemfig{BF_3}}][\parbox{1.2cm}{2) \chemfig{H_2O}}] \& \acetylfuran \\ +furan \& \& acetylclorhyde \& \& 2-acetylfuran \\ +\end{quickreaction} +\end{center} + +\subsection{Multiple Labels} +Similarly to the previous example, reactions with multiple consecutive steps can be set using \lstinline{\parbox}. + +\begin{lstlisting} +%Preamble +|\usepackage{xparse} +\usepackage{tikz} +\usepackage{chemfig} +\usepackage[iupac]{quickreaction}| + +%C(CC(=O)OCC)(=O)OCC +\newcommand{\diethylmalonate}{\chemfig{-[:30]-[:-30]O-[:30](=[:90]O)-[:-30]-[:30](=[:90]O)-[:-30]O-[:30]-[:-30]}} +\newcommand{\malonicproduct}{\chemfig{HO-[:30](=[:90]O)-[:-30](-[:-90]R_2)-[:30]R_1}} +%Document +\begin{quickreaction} +\diethylmalonate \& \quickarrow[\parbox{1.8cm}{1) \chemfig{OEt^{-}} \\ 2) \chemfig{R_1-Br}}][\parbox{1.8cm}{3) \chemfig{OEt^{-}} \\ 4) \chemfig{R_2-Br} \\ 5) \chemfig{H_3O^{+}}, $\Delta$}] \& \malonicproduct \\ +diethylmalonate \& \& \\ +\end{quickreaction} + +\end{lstlisting} + +\begin{center} +\begin{quickreaction} +\diethylmalonate \& \quickarrow[\parbox{1.8cm}{1) \chemfig{OEt^{-}} \\ 2) \chemfig{R_1-Br}}][\parbox{1.8cm}{3) \chemfig{OEt^{-}} \\ 4) \chemfig{R_2-Br} \\ 5) \chemfig{H_3O^{+}}, $\Delta$}] \& \chemfig{HO-[:30](=[:90]O)-[:-30](-[:-90]R_2)-[:30]R_1} \\ +diethylmalonate \& \& \\ +\end{quickreaction} +\end{center} + +\subsection{Adjusting Column and Row Spacing} +This is only the application of some examples from the \href{https://tikz.dev/tikz-matrices#sec-20.3.2}{\ttfamily Tikz manual}. To adjust the spacing between two specific columns or rows you can add a positive or negative length value as \lstinline{[length]} after \lstinline{\&} for adjusting row spacing or after \lstinline{\\} for adjusting column spacing. + +\begin{lstlisting} +%Document +\begin{quickreaction} +\diethylmalonate \& \quickarrow[\parbox{1.8cm}{1) \chemfig{OEt^{-}} \\ 2) \chemfig{R_1-Br}}][\parbox{1.8cm}{3) \chemfig{OEt^{-}} \\ 4) \chemfig{R_2-Br} \\ 5) \chemfig{H_3O^{+}}, $\Delta$}] \& \malonicproduct \\[-1cm] +|diethylmalonate| \& \& \\ +\end{quickreaction} +\end{lstlisting} + +\begin{center} +\begin{quickreaction} +\diethylmalonate \& \quickarrow[\parbox{1.8cm}{1) \chemfig{OEt^{-}} \\ 2) \chemfig{R_1-Br}}][\parbox{1.8cm}{3) \chemfig{OEt^{-}} \\ 4) \chemfig{R_2-Br} \\ 5) \chemfig{H_3O^{+}}, $\Delta$}] \& \chemfig{HO-[:30](=[:90]O)-[:-30](-[:-90]R_2)-[:30]R_1} \\[-1cm] +diethylmalonate \& \& \\ +\end{quickreaction} +\end{center} + +\begin{lstlisting} +%Document +\begin{quickreaction} +\diethylmalonate \&[0.5cm] \quickarrow[\parbox{1.8cm}{1) \chemfig{OEt^{-}} \\ 2) \chemfig{R_1-Br}}][\parbox{1.8cm}{3) \chemfig{OEt^{-}} \\ 4) \chemfig{R_2-Br} \\ 5) \chemfig{H_3O^{+}}, $\Delta$}] \&[0.5cm] \chemfig{HO-[:30](=[:90]O)-[:-30](-[:-90]R_2)-[:30]R_1} \\ +|diethylmalonate| \& \& \\ +\end{quickreaction} +\end{lstlisting} + +\begin{center} +\begin{quickreaction} +\diethylmalonate \&[0.5cm] \quickarrow[\parbox{1.8cm}{1) \chemfig{OEt^{-}} \\ 2) \chemfig{R_1-Br}}][\parbox{1.8cm}{3) \chemfig{OEt^{-}} \\ 4) \chemfig{R_2-Br} \\ 5) \chemfig{H_3O^{+}}, $\Delta$}] \&[0.5cm] \chemfig{HO-[:30](=[:90]O)-[:-30](-[:-90]R_2)-[:30]R_1} \\ +diethylmalonate \& \& \\ +\end{quickreaction} +\end{center} + +\subsection{Auto-adjusting Column Spacing for Large Labels} +When the above arrow label is higher than the depth of the deepest molecule, molecules names get shifted down to preserve the symmetry of the entire reaction box. +\begin{lstlisting} +%Preamble +|\usepackage{xparse} +\usepackage{tikz} +\usepackage{chemfig} +\usepackage{mol2chemfig} +\usepackage[iupac]{quickreaction}| + +%CC(=O)C +\newcommand{\acetone}{\chemfig{-[:90](-[:150])=[:30]O}} +%C1=CC(=CC=C1C=O)Cl +\newcommand{\chlorobenzaldehyde}{\chemfig{O=[:300](-[:-120]H)--[:300,,,,dlh]--[:60,,,,dlh](-Cl)-[:120]-[:180,,,,dlh](-[:240])}} +%C1C[C@H](NC1)C(=O)O +\newcommand{\Lproline}{\chemfig{O=[:132](-[:72,,,1]OH)>[:192]-[:138]-[:210]-[:282]-[:354]\mcfbelow{N}{H}(-[:66])}} +\newcommand{\clhydroxybutanone}{\chemfig{-[:300](=[:240]O)--[:60](<:[:120,,,2]HO)--[:300,,,,dlh]--[:60,,,,dlh](-Cl)-[:120]-[:180,,,,dlh](-[:240])}} + +%Document +\begin{quickreaction} +\acetone \& + \& \chlorobenzaldehyde \& \quickarrow[\Lproline] \& \clhydroxybutanone\\ +acetone \& \& 4-chlorobenzaldehyde \& \& 4-(4-chlorophenyl)-4-hydroxy-2-butanone \\ +\end{quickreaction} +\end{lstlisting} + +\begin{center} +\begin{quickreaction} +\acetone \& + \& \chlorobenzaldehyde \& \quickarrow[\Lproline] \& \clhydroxybutanone\\ +acetone \& \& 4-chlorobenzaldehyde \& \& 4-(4-chlorophenyl)-4-hydroxy-2-butanone \\ +\end{quickreaction} +\end{center} + +To replace them at their standard distance, add the deepest molecule and the entire \lstinline{\quickarrow[\Lproline]} as two optional argument of the environment to compute and store the negative shift to apply and specify the stored length with \lstinline{\fixrow}. + +\begin{lstlisting} +%Document +\begin{quickreaction}[\quickarrow[\Lproline]][\clhydroxybutanone] +\acetone \& + \& \chlorobenzaldehyde \& \quickarrow[\Lproline] \& \clhydroxybutanone\\[\fixrow] +|acetone| \& \& |4-chlorobenzaldehyde| \& \& 4-(4-chlorophenyl)-4-hydroxy-2-butanone \\ +\end{quickreaction} +\end{lstlisting} + +\begin{center} +\begin{quickreaction}[\clhydroxybutanone][\quickarrow[\Lproline]] +\acetone \& + \& \chlorobenzaldehyde \& \quickarrow[\Lproline] \& \clhydroxybutanone\\[\fixrow] +acetone \& \& 4-chlorobenzaldehyde \& \& 4-(4-chlorophenyl)-4-hydroxy-2-butanone \\ +\end{quickreaction} +\end{center} + +\end{document} diff --git a/graphics/pstricks/contrib/pst-func/Changes b/graphics/pstricks/contrib/pst-func/Changes index 4c691ca094..69897279a4 100644 --- a/graphics/pstricks/contrib/pst-func/Changes +++ b/graphics/pstricks/contrib/pst-func/Changes @@ -1,4 +1,5 @@ ..... pst-func.tex +1.02 2023-04-14 - added \psNonCentralFDist (noncentral F-distribution) 1.01 2023-04-02 - added \psNonCentralTDist (noncentral Student's distribution) 1.00 2022-09-11 - fix \psBessel: use toDeg instead of k - set algebraic=false @@ -122,6 +123,7 @@ ..... pst-func.pro +0.20 2023-04-04 - make epsX more sensitive 0.19 2023-04-02 - added /ConfHyperFunc { % Confluent Hypergeometric Function of the First Kind needed by \psNonCentralTDist 0.18 2021-10-30 - added arraysum and arrayprod diff --git a/graphics/pstricks/contrib/pst-func/doc/pst-func-doc.pdf b/graphics/pstricks/contrib/pst-func/doc/pst-func-doc.pdf index 62249b7e51..8b47c2fd9b 100644 Binary files a/graphics/pstricks/contrib/pst-func/doc/pst-func-doc.pdf and b/graphics/pstricks/contrib/pst-func/doc/pst-func-doc.pdf differ diff --git a/graphics/pstricks/contrib/pst-func/doc/pst-func-doc.tex b/graphics/pstricks/contrib/pst-func/doc/pst-func-doc.tex index b3f0c2ecae..8180a0e80e 100644 --- a/graphics/pstricks/contrib/pst-func/doc/pst-func-doc.tex +++ b/graphics/pstricks/contrib/pst-func/doc/pst-func-doc.tex @@ -1,6 +1,6 @@ \RequirePackage{pdfmanagement-testphase} \DeclareDocumentMetadata{} -%% $Id: pst-func-doc.tex 691 2023-04-03 10:51:04Z herbert $ +%% $Id: pst-func-doc.tex 697 2023-04-14 10:17:32Z herbert $ \documentclass[fontsize=11pt,english,BCOR=10mm,DIV=12,bibliography=totoc,parskip=false,headings=small, headinclude=false,footinclude=false,oneside]{pst-doc} \usepackage{pst-func} @@ -1435,7 +1435,8 @@ and is predefined with 5. \subsection{Binomial distribution}\label{sec:bindistri} \begin{sloppypar} -The following five macros plot binomial probability mass function \Lcs{psBinomial} and \Lcs{psBinomialC} in curve style, the normalized one is \Lcs{psBinomialN}. The cumulative distribution function $F$ \Lcs{psBinomialF} and the complement of the cumulative distribution function ($1-F$) \Lcs{psBinomialFS} +The following five macros plot binomial probability mass function \Lcs{psBinomial} and \Lcs{psBinomialC} in curve style, the normalized one is \Lcs{psBinomialN}. The cumulative distribution function +$F$ \Lcs{psBinomialF} and the complement of the cumulative distribution function ($1-F$) \Lcs{psBinomialFS} The vertical range for the plots is the $y$-Intervall $[0;1]$. Rescaling other values can be done by setting the \Lkeyword{yunit} option to any other value. @@ -2008,6 +2009,111 @@ The default settings are $\mu=1$ and $\nu=1$. \end{LTXexample} \clearpage + +\subsection{Noncentral $F$-distribution} + +The noncentral F-distribution is given by + + +\begin{align} +P(x)=\sum\limits_{k=0}^{\infty}{\frac{e^{-\lambda/2}(\lambda/2)^{k}} + {B\left({\frac {\nu_{2}}{2}},{\frac {\nu _{1}}{2}}+k\right)k!}} +\left({\frac {\nu _{1}}{\nu _{2}}}\right)^{{\frac {\nu _{1}}{2}}+k} + \left({\frac {\nu _{2}}{\nu_{2} + +\nu _{1}f}}\right)^{{\frac{\nu_{1} + +\nu _{2}}{2}}+k}x^{\nu_{1}/2-1+k} +\end{align} + + +\iffalse +\begin{align} +P(x) &= e^\frac{\frac{-\lambda}2+(\lambda n_1x)}{2(n_2+n_1x)} +n_1^{\frac{n_1}2} n_2^{\frac{n_2}2} x^{\frac{n_1}2-1} +(n_2+n_1x)^{\frac{-(n_1+n_2)}2} +\frac{\Gamma(\frac12 n_1)\Gamma\left(1+\frac12 n_2\right) + \mathop{L}_\frac{n_2}2^{\frac{n_1}2-1}\left(-\frac{\lambda n_1 x}{2(n_2+n_1x)}\right)} + {B\left(\frac12 n_1,\frac12 n_2\right)\Gamma\left(\frac12 (n_1+n_2)\right)} +\\ + &= \frac1{B\left(\frac12 n_1,\frac12 n_2\right)} + \left( + e^{\frac\lambda2}n_1^{\frac{n_1}2} n_2^{\frac{n_2}2} x^{\frac{n_1}2-1} + (n_2+n_1x)^{\frac{-(n_1+n_2)}2} + {}_1F_1\left( \frac12(n_1+n_2); \, \frac12n_1; \, \frac{\lambda n_1 x}{2(n_2+n_1x)} \right) + \right) +\end{align} + + +%(e^(lambda/2)x^(n_1/2-1)(xn_1+n_2)^(-(n_1+n_2)/2)n_1^(n_1/2)n_2^(n_2/2)_1F_1(1/2(n_1+n_2);1/2n_1;(xlambdan_1)/(2(xn_1+n_2)))), +%\] + +\fi + + +where %$\Gamma(z)$ is the gamma function, +$B(\alpha,\beta)$ is the beta function + +\begin{align} +B(p,q) &= \frac{\Gamma(p)\Gamma(q)}{\Gamma(p+q)}\\ + &= \frac{(p-1)!(q-1)!}{(p+q-1)!} +\end{align} + +\iffalse + and $L_m^n(z)$ is a generalized Laguerre polynomial. + + \begin{align} +% L_n(x) &= \sum_{k=0}^n \frac{(-1)^k}{k!} \binom{n}{k} x^k \\ +L_n^{k(x)} &= \frac{e^xx^{-k}}{n!} \frac{d^n}{dx^n} e^{-x}x^{n+k} \\ + &= (-1)^k \frac{d^k}{dx^k} L_{n+k}(x)\\ + &= \frac{(-1)^nx^(-(k+1)/2)}{n!} e^\frac x2 W_{\frac k2+n+\frac12, \frac k2}(x)\\ + &= \sum_{m=0}^n(-1)^m \frac{(n+k)!}{(n-m)!(k+m)!m!}x^m + \end{align} + +where $W_{k,m}(x)$ is a Whittaker function. + +\fi + + + +\begin{BDef} +\Lcs{psNonCentralFDist}\OptArgs\Largb{x0}\Largb{x1} +\end{BDef} +% +The default settings are $\mu=1$, $\nu=1$ and $\lambda=0$, which is the same as the default F-distribution. + +\begin{LTXexample}[pos=t,preset=\centering] +\psset{xunit=1cm,yunit=10cm} +\begin{pspicture*}(-2,-0.02)(10.5,1.1) +\psset{linewidth=1pt} +% \psFDist[linecolor=blue,mue=5,nue=20,lambda=0]{0.01}{5} +\psaxes[Dy=0.1]{->}(0,0)(10,1) +\psFDist[linecolor=red,mue=5,nue=20]{0.01}{10} +\psNonCentralFDist[linecolor=green,mue=5,nue=20,lambda=1.6]{0.01}{10} +\end{pspicture*} +\end{LTXexample} + + +\begin{LTXexample}[pos=t,preset=\centering] +\psset{xunit=2cm,yunit=10cm,plotpoints=100} +\begin{pspicture*}(-0.5,-0.07)(5.5,0.8) + \psline[linestyle=dashed](0.5,0)(0.5,0.75) + \psline[linestyle=dashed](! 2 7 div 0)(! 2 7 div 0.75) + \psset{linewidth=1pt} + \psFDist{0.1}{5} + \psFDist[linecolor=red,mue=5,nue=20]{0.01}{5} + \psNonCentralFDist[linecolor=green,mue=5,nue=20,lambda=1.6]{0.01}{5} + \psNonCentralFDist[linecolor=blue,nue=5,mue=20,lambda=1.6]{0.01}{5} + \psFDist[linecolor=blue,mue=12,nue=3]{0.01}{5} + \psNonCentralFDist[linecolor=green,mue=12,nue=3,lambda=1.6]{0.01}{5} + \psaxes[Dy=0.1]{->}(0,0)(5,0.75) +\end{pspicture*} +\end{LTXexample} + + + + + +\clearpage + \subsection{Beta distribution} A general type of statistical distribution which is related to the gamma distribution. diff --git a/graphics/pstricks/contrib/pst-func/dvips/pst-func.pro b/graphics/pstricks/contrib/pst-func/dvips/pst-func.pro index a0a58d9e92..be37da189c 100644 --- a/graphics/pstricks/contrib/pst-func/dvips/pst-func.pro +++ b/graphics/pstricks/contrib/pst-func/dvips/pst-func.pro @@ -1,4 +1,4 @@ -%% $Id: pst-func.pro 689 2023-04-03 06:46:27Z herbert $ +%% $Id: pst-func.pro 694 2023-04-05 19:17:32Z herbert $ %% %% This is file `pst-func.pro', %% @@ -16,25 +16,36 @@ %% `pst-func' is a PSTricks package to plot special math functions %% %% -%% version 0.19 / 2023-04-02 Herbert Voss +%% version 0.20 / 2023-04-04 Herbert Voss % /tx@FuncDict 100 dict def tx@FuncDict begin % -/eps1 1.0e-05 def -/eps2 1.0e-04 def +/eps4 1.0e-04 def /eps5 1.0e-05 def /eps8 1.0e-08 def % /PiHalf 1.57079632679489661925640 def /CEuler 0.5772156649 def % Euler-Mascheroni constant % -/factorial { % n on stack, returns n! - dup 32 gt { pop 1e32 } { - dup 0 eq { 1 }{ - dup 1 gt { dup 1 sub factorial mul } if } - ifelse } ifelse -} def +/factorialR { + dup 1e32 gt { pop 1e32 } { + dup 0 eq % check for the argument being 0 + { pop 1 } % if so, the result is 1 + { dup 1 sub factorial % call recursively with n - 1 + mul % multiply the result with n + } ifelse + } ifelse +} def +% +%Iterative +/factorial { + 1 % initial value for the product + 1 1 % for's start value and increment + 4 -1 roll % bring the argument to the top as for's end value + { mul } for +} def +% % /MoverN { % m n on stack, returns the binomial coefficient m over n 2 dict begin @@ -195,14 +206,14 @@ tx@FuncDict begin { /Iter Iter 1 add def Nx func /F exch def % f(Nx) - F abs eps2 lt { exit } if + F abs eps4 lt { exit } if Nx func' /FS exch def % f'(Nx) FS 0 eq { /FS 1.0e-06 def } if Nx func'' /F2S exch def % f''(Nx) 1.0 1.0 F F2S mul FS dup mul div sub div /J exch def J F mul FS div /Diff exch def /Nx Nx Diff sub def - Diff abs eps1 lt Iter MaxIter gt or { exit } if + Diff abs eps5 lt Iter MaxIter gt or { exit } if } loop Nx % the returned value ist the zero point } def @@ -212,13 +223,13 @@ tx@FuncDict begin /Iter 0 def /MaxIter 200 def { pstack y0 func /F exch def - F abs eps2 lt { exit } if + F abs eps4 lt { exit } if y0 F sub /Phi exch def Phi func /F2 exch def - F2 abs eps2 le { exit }{ + F2 abs eps4 le { exit }{ Phi y0 sub dup mul Phi F2 sub 2 Phi mul sub y0 add Div /Diff exch def y0 Diff sub /y0 exch def - Diff abs eps1 le { exit } if + Diff abs eps5 le { exit } if } ifelse /Iter Iter 1 add def Iter MaxIter gt { exit } if @@ -371,7 +382,7 @@ tx@FuncDict begin % https://mathworld.wolfram.com/ConfluentHypergeometricFunctionoftheFirstKind.html /ConfHyperFunc { % Confluent Hypergeometric Funtion of the First Kind % on stack must be a b z - 10 dict begin + 15 dict begin /z ED /b ED /a ED /sum 1 def /k 0 def @@ -389,6 +400,19 @@ tx@FuncDict begin end } def % +% https://mathworld.wolfram.com/BetaFunction.html +/BETA {% BETA function ((p-1)!(q-1)!)/(p+q-1)! + % on stack must be p q + 2 dict begin + /q ED + /p ED + p 1 sub factorial q 1 sub factorial + mul + p q add 1 sub factorial + div + end +} def +% end % /arraySum { % on stack the array diff --git a/graphics/pstricks/contrib/pst-func/latex/pst-func.sty b/graphics/pstricks/contrib/pst-func/latex/pst-func.sty index c97e1968b1..7d63925ab4 100644 --- a/graphics/pstricks/contrib/pst-func/latex/pst-func.sty +++ b/graphics/pstricks/contrib/pst-func/latex/pst-func.sty @@ -5,12 +5,14 @@ \RequirePackage{pst-tools} \RequirePackage{pstricks-add} \RequirePackage{pst-xkey} +\RequirePackage{iftex} +\ifluatex \RequirePackage{luacode} \fi % \input{pst-func.tex} \ProvidesFile{pst-func.tex} [\filedate\space v\fileversion\space `PST-func' (hv)] \IfFileExists{pst-func.pro}{% - \ProvidesFile{pst-func.pro}[2023/04/02 v. 0.19, PostScript prologue file (hv)] + \ProvidesFile{pst-func.pro}[2023/04/04 v. 0.20, PostScript prologue file (hv)] \@addtofilelist{pst-func.pro}}{}% \endinput -%% $Id: pst-func.sty 693 2023-04-03 10:56:01Z herbert $ +%% $Id: pst-func.sty 698 2023-04-14 10:19:52Z herbert $ diff --git a/graphics/pstricks/contrib/pst-func/tex/pst-func.tex b/graphics/pstricks/contrib/pst-func/tex/pst-func.tex index 7960baf61b..786942a07a 100644 --- a/graphics/pstricks/contrib/pst-func/tex/pst-func.tex +++ b/graphics/pstricks/contrib/pst-func/tex/pst-func.tex @@ -1,4 +1,4 @@ -%% $Id: pst-func.tex 689 2023-04-03 06:46:27Z herbert $ +%% $Id: pst-func.tex 697 2023-04-14 10:17:32Z herbert $ %% %% This is file `pst-func.tex', %% @@ -31,8 +31,8 @@ % interface to the `xkeyval' package \pst@addfams{pst-func} % -\def\fileversion{1.01} -\def\filedate{2023/04/02} +\def\fileversion{1.02} +\def\filedate{2023/04/14} \message{`PST-func' v\fileversion, \filedate\space (hv)} % \pstheader{pst-func.pro} @@ -1572,6 +1572,60 @@ grestore \fi% \ignorespaces% } +% +\def\psNonCentralFDist{\pst@object{psNonCentralFDist}} +\def\psNonCentralFDist@i#1#2{% + \ifdim#1pt<\z@ \psframebox*{\color{red}!!!\#1 must be greater than 0!!!} + \else + \leavevmode + \pst@killglue + \begingroup + \addbefore@par{plotpoints=500,nue=1,mue=1,lambda=0}% + \use@par + \iffalse %\ifluatex for later use + \luaexec{ require("pst-func") + printDataPlotFileFDist(#1,#2,\psk@plotpoints,\psk@mue,\psk@nue,\psk@lambda,"\jobname-lua","true") }% + \fileplot{\jobname-lua.data}% + \else + \psplot[algebraic=false]{#1}{#2}[/F_BETA \psk@mue 2 div \psk@nue 2 div tx@FuncDict begin BETA end def]{ + /constA Euler \psk@lambda -2 div exp def + /Sum + constA F_BETA +% \psk@nue 2 div \psk@mue 2 div tx@FuncDict begin BETA end + div % first fraction + \psk@mue \psk@nue div \psk@mue 2 div exp + mul + \psk@nue dup \psk@mue x mul add div \psk@mue \psk@nue add 2 div exp + mul + x \psk@mue 2 div 1 sub exp + mul + def + /K 1 def + { + constA \psk@lambda 2 div K exp mul % nominator + \psk@nue 2 div \psk@mue 2 div K add tx@FuncDict begin BETA end K factorial mul % denominator + div % first fraction + \psk@mue \psk@nue div \psk@mue 2 div K add exp + mul + \psk@nue dup \psk@mue x mul add div \psk@mue \psk@nue add 2 div K add exp + mul + x \psk@mue 2 div 1 sub K add exp + mul + dup abs 1e-5 lt + { pop exit } + { Sum add /Sum ED + K 1 add /K ED } ifelse + K 100 ge { (Error ConfHyperFunc: K=100) == exit } if + } loop + Sum + }% + \fi + \endgroup + \fi + \ignorespaces +} + + % \define@key[psset]{pst-func}{m}[0]{\def\psk@cauchy@m{#1 }} \define@key[psset]{pst-func}{b}[1]{\def\psk@cauchy@b{#1 }} -- cgit v1.2.3