summaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-10-10 03:03:17 +0000
committerNorbert Preining <norbert@preining.info>2022-10-10 03:03:17 +0000
commit9c7942efff8183c8695ec824008847dd068dbfe7 (patch)
treee33fd003ccafdc5be2fae32625d9dd06c6e339b6 /graphics
parentfec5c6c870d9c855fe6be355b088ca729184bdff (diff)
CTAN sync 202210100303
Diffstat (limited to 'graphics')
-rw-r--r--graphics/chemobabel/README.md2
-rw-r--r--graphics/chemobabel/chemobabel-en.pdfbin548875 -> 568562 bytes
-rw-r--r--graphics/chemobabel/chemobabel-ja.pdfbin651493 -> 672338 bytes
-rw-r--r--graphics/chemobabel/chemobabel.dtx261
-rw-r--r--graphics/chemobabel/chemobabel.sty230
-rw-r--r--graphics/chemobabel/example-en.tex9
-rw-r--r--graphics/chemobabel/example-ja.tex9
7 files changed, 344 insertions, 167 deletions
diff --git a/graphics/chemobabel/README.md b/graphics/chemobabel/README.md
index dc09ba6836..397c15cad3 100644
--- a/graphics/chemobabel/README.md
+++ b/graphics/chemobabel/README.md
@@ -43,7 +43,7 @@ This work is based on a lot of resources published online:
## Release Date
-2022-09-19
+2022-10-09
--------------------
Hironobu YAMASHITA (aka. "Acetaminophen" or "@aminophen")
diff --git a/graphics/chemobabel/chemobabel-en.pdf b/graphics/chemobabel/chemobabel-en.pdf
index 773b7fc51b..381d065821 100644
--- a/graphics/chemobabel/chemobabel-en.pdf
+++ b/graphics/chemobabel/chemobabel-en.pdf
Binary files differ
diff --git a/graphics/chemobabel/chemobabel-ja.pdf b/graphics/chemobabel/chemobabel-ja.pdf
index 3c08f8d315..f1a7cdc368 100644
--- a/graphics/chemobabel/chemobabel-ja.pdf
+++ b/graphics/chemobabel/chemobabel-ja.pdf
Binary files differ
diff --git a/graphics/chemobabel/chemobabel.dtx b/graphics/chemobabel/chemobabel.dtx
index ba4bf4df70..2158f591a9 100644
--- a/graphics/chemobabel/chemobabel.dtx
+++ b/graphics/chemobabel/chemobabel.dtx
@@ -28,20 +28,26 @@
% --- (Japanese jsarticle style => English style)
\makeatletter
\long\def\@makecaption#1#2{%
-\vskip\abovecaptionskip
-\sbox\@tempboxa{#1: #2}
-\global\@minipagefalse
-\hbox to\hsize{\hfil\box\@tempboxa\hfil}
-\vskip\belowcaptionskip}
+ \vskip\abovecaptionskip
+ \sbox\@tempboxa{#1: #2}%
+ \global\@minipagefalse
+ \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
+ \vskip\belowcaptionskip}
\makeatother
% --- XyMTeX logo definition
\newcount\TestCount
-\def\XyM{\ifnum\fam=-1\relax\fam=0\relax\fi\TestCount=\fam%
-X\kern-.30em\smash{\raise.50ex\hbox{$\fam\TestCount\Upsilon$}}%
-\kern-.30em{M}}
+\def\XyM{\ifnum\fam=-1\relax\fam=0\relax\fi\TestCount=\fam
+ X\kern-.30em\smash{\raise.50ex\hbox{$\fam\TestCount\Upsilon$}}%
+ \kern-.30em{M}}
\def\XyMTeX{\XyM\kern-.1em\TeX}
+% --- misc
+\def\Lpack#1{\textsf{#1}}
+\def\Lcode#1{\texttt{#1}}
+\def\Lmeta#1{\textit{#1}}
+\def\Lver#1{\Lpack{chemobabel} #1}
+\def\TikZ{Ti\textit{k}Z}
% ------
-\title{\textsf{chemobabel} \\[1ex]
+\title{\Lpack{chemobabel} \\[1ex]
\normalsize --- Chemical Structures from MDL Molfiles,
ChemDraw Files or SMILES Notations --- \\
%<ja> 化学構造式をMOLファイルやChemDrawファイル,SMILES表記法から自動生成
@@ -53,7 +59,7 @@ X\kern-.30em\smash{\raise.50ex\hbox{$\fam\TestCount\Upsilon$}}%
\maketitle
%<*en>
-This document (\jobname.pdf) describes the usage of \textsf{chemobabel.sty},
+This document (\jobname.pdf) describes the usage of \Lpack{chemobabel.sty},
a \LaTeX\ package for \textbf{generating chemical structural formulas}
to be inserted in your documents.
The formulas can be generated \textbf{from many kinds of chemical data
@@ -65,7 +71,7 @@ The formulas below are generated using this method.
%</en>
%<*ja>
この文書では,\textbf{化学構造式を生成}して\LaTeX の文書中に挿入するための
-パッケージである\textsf{chemobabel.sty}と同梱リソースの使い方を説明します。
+パッケージである\Lpack{chemobabel.sty}と同梱リソースの使い方を説明します。
構造式はOpen Babelの機能を利用することにより,MDL Molfile, ChemDrawファイル,
さらにはSMILES表記法を含む\textbf{さまざまな化学データ形式から生成}できます。
以下の構造式はこの方法によって出力されたものです。
@@ -76,14 +82,14 @@ For English documentation, please refer to chemobabel-en.pdf.
\begin{figure}[ht]
\centering
\chemobabel[width=65mm]{draw/Firefly luciferin.mol}{} \quad
- \chemobabel[width=90mm]{draw/Brevetoxin A.mol}{}
+ \chemobabel*[width=90mm]{draw/Brevetoxin A.mol}
\caption{Firefly luciferin \& Brevetoxin A (from MDL Molfiles)}
\end{figure}
\begin{figure}[ht]
\centering
\chemobabel[width=90mm]{draw/ATP.cdx}{} \hspace{1cm}
- \chemobabel[width=35mm]{draw/Glucose.cdx}{}
+ \chemobabel*[width=35mm]{draw/Glucose.cdx}
\caption{ATP (Adenosine triphosphate) \& Glucose (from ChemDraw files)}
\end{figure}
\begin{center}\small
@@ -94,15 +100,15 @@ becomes wrong.\\ See \url{https://github.com/openbabel/openbabel/issues/338}
\begin{figure}[ht]
\centering
\smilesobabel[width=36mm]{CCO}{} \hspace{1cm}
- \smilesobabel[width=40mm]{CC(C(=O)O)N}{} \hspace{1cm}
- \smilesobabel[width=30mm]{C1[C@H](C)C[C@@H](O)C1}{}
+ \smilesobabel*[width=40mm]{CC(C(=O)O)N} \hspace{1cm}
+ \smilesobabel*[width=30mm]{C1[C@H](C)C[C@@H](O)C1}
\caption{Ethanol, Alanine \& (1\textit{S},3\textit{S})-3-Methylcyclopentanol (from SMILES notations)}
\end{figure}
\begin{figure}[ht]
\centering
- \smilesobabel[width=30mm]{CC(=O)Nc1ccc(cc1)O}{} \hspace{1cm}
- \smilesobabel[width=40mm]{C([C@@H]1[C@H]([C@@H]([C@H]([C@H](O1)O)O)O)O)O}{}
+ \smilesobabel*[width=30mm]{CC(=O)Nc1ccc(cc1)O} \hspace{1cm}
+ \smilesobabel*[width=40mm]{C([C@@H]1[C@H]([C@@H]([C@H]([C@H](O1)O)O)O)O)O}
\caption{Acetaminophen (Paracetamol) \& $\alpha$-\textsc{d}-Glucose (from SMILES notations)}
\end{figure}
@@ -158,8 +164,8 @@ Some \TeX/\LaTeX\ macros and packages are already available from
\begin{itemize}
\item \href{http://www.ctan.org/pkg/xymtex}{\XyMTeX}:
a set of packages for drawing chemical structural formulas
-\item \href{http://www.ctan.org/pkg/chemfig}{\textsf{chemfig}}:
- a package which draws molecules using Ti\textit{k}Z
+\item \href{http://www.ctan.org/pkg/chemfig}{\Lpack{chemfig}}:
+ a package which draws molecules using \TikZ
\end{itemize}
These packages are reliable and almost all kinds of structural formulas
can be drawn in a consistent way. However, a lot of practice will be
@@ -170,8 +176,8 @@ required before one can come to make full use of them.
\begin{itemize}
\item \href{http://www.ctan.org/pkg/xymtex}{\XyMTeX}:
化学構造式を描くためのパッケージ集
- \item \href{http://www.ctan.org/pkg/chemfig}{\textsf{chemfig}}:
- Ti\textit{k}Zを利用して構造式を描画するパッケージ
+ \item \href{http://www.ctan.org/pkg/chemfig}{\Lpack{chemfig}}:
+ \TikZ を利用して構造式を描画するパッケージ
\end{itemize}
これらのパッケージは確実で,あらゆる構造式を一貫性をもって描画することができます。
しかし,十分にその機能を活用できるようになるには相当の熟練を要します。
@@ -196,7 +202,7 @@ In this case, you have to save files in both chemical formats
%</ja>
%<*en>
-This new package, \textsf{chemobabel.sty}, will offer a new choice for
+This new package, \Lpack{chemobabel.sty}, will offer a new choice for
chemists who need chemical structures inserted in their \LaTeX\ documents.
In this method, we use \href{http://openbabel.org/}{Open Babel} for
generating chemical structural formulas in SVG format,
@@ -204,7 +210,7 @@ and \href{https://inkscape.org/en/}{Inkscape} for converting SVG to PDF.
Both programs are open source and cross-platform, and being actively maintained.
%</en>
%<*ja>
-新しいパッケージ \textsf{chemobabel.sty} は,\LaTeX 文書中に化学構造式を
+新しいパッケージ \Lpack{chemobabel.sty} は,\LaTeX 文書中に化学構造式を
挿入する必要がある化学者に新たな選択肢を提供することでしょう。
この方法では,\href{http://openbabel.org/}{Open Babel}によって
SVG形式の構造式画像を生成し,
@@ -300,15 +306,15 @@ First, you have to install \href{http://openbabel.org/}{Open Babel} and
\href{https://inkscape.org/en/}{Inkscape}
(or \href{http://librsvg.sourceforge.net/download/}{librsvg}) on your
computer, and export PATH to the command-line binary of both programs,
-\verb+obabel+ and \verb+inkscape+ (or \verb+rsvg-convert+).
+\Lcode{obabel} and \Lcode{inkscape} (or \Lcode{rsvg-convert}).
You can confirm by executing following commands:
%</en>
%<*ja>
初めにコンピュータに\href{http://openbabel.org/}{Open Babel}と
\href{https://inkscape.org/ja/}{Inkscape}(または
\href{http://librsvg.sourceforge.net/download/}{librsvg})をインストールし,
-コマンドライン実行ファイルである\verb+obabel+と\verb+inkscape+
-(または\verb+rsvg-convert+)にPATHを通します。
+コマンドライン実行ファイルである
+\Lcode{obabel}と\Lcode{inkscape}(または\Lcode{rsvg-convert})にPATHを通します。
正しくPATHが通っているかどうかは以下のコマンドによって確認できます:
%</ja>
%<en>In UNIX operating system:
@@ -346,17 +352,17 @@ In the preamble of your document, declare
\begin{verbatim}
\usepackage{chemobabel}
\end{verbatim}
-to load \textsf{chemobabel} package.
-The package depends on \textsf{graphicx}.
+to load \Lpack{chemobabel} package.
+The package depends on \Lpack{graphicx}.
%</en>
%<*ja>
プリアンブルに
\begin{verbatim}
\usepackage{chemobabel}
\end{verbatim}
-と宣言して\textsf{chemobabel}パッケージを読み込みます。
-これは\textsf{graphicx}パッケージに依存しますので,
-もし(u)p\LaTeX を使っていてDVIドライバに\texttt{dvipdfmx}を使用する場合は
+と宣言して\Lpack{chemobabel}パッケージを読み込みます。
+これは\Lpack{graphicx}パッケージに依存しますので,
+もし(u)p\LaTeX を使っていてDVIドライバに\Lcode{dvipdfmx}を使用する場合は
ドライバオプション \verb+[dvipdfmx]+ をクラスオプション(グローバル)に
付けるのを忘れないようにしてください。
%</ja>
@@ -385,7 +391,7 @@ of ATP (Adenosine triphosphate) drawn in ChemDraw, and
\href{http://www.chemspider.com/}{ChemSpider} (originally \verb|9041092.mol|).
Use \verb|\chemobabel| command as follows. I put original files in a
-subdirectory \texttt{draw}, so added \texttt{draw/} before the actual filename.
+subdirectory \Lcode{draw}, so added \Lcode{draw/} before the actual filename.
Of course you can put in the same directory with your \LaTeX\ file.
%</en>
%<*ja>
@@ -395,14 +401,14 @@ ChemDrawで描画したファイル,\verb|Brevetoxin A.mol| は
(もとのファイル名は \verb|9041092.mol| となっています)。
\verb|\chemobabel| コマンドは本文中で以下のようにして使います。
-ここでは元のファイルを\texttt{draw}というサブディレクトリに置いたので,
-ファイル名の前に \texttt{draw/} を付けました。
+ここでは元のファイルを\Lcode{draw}というサブディレクトリに置いたので,
+ファイル名の前に \Lcode{draw/} を付けました。
もちろん \LaTeX ソースと同一ディレクトリに置くこともできます。
%</ja>
\begin{verbatim}
\chemobabel[width=90mm]{draw/ATP.cdx}{}
-\chemobabel[width=120mm]{draw/Brevetoxin A.mol}{}
+\chemobabel*[width=120mm]{draw/Brevetoxin A.mol}
\end{verbatim}
%<*en>
@@ -434,34 +440,44 @@ $ dvipdfmx test.dvi
\begin{figure}[h]
\centering
\chemobabel[width=90mm]{draw/ATP.cdx}{} \\ \vspace{1cm}
- \chemobabel[width=120mm]{draw/Brevetoxin A.mol}{}
+ \chemobabel*[width=120mm]{draw/Brevetoxin A.mol}
\caption{Conversion from ATP.cdx and Brevetoxin A.mol}\label{fig:chem1}
\end{figure}
%<en>The syntax is:
%<ja>構文は以下のとおりです。
\begin{center}
-\verb|\chemobabel[|\textit{options}\verb|]{|\textit{filename}\verb|}{|\textit{obabel options}\verb|}|
+\verb|\chemobabel[|\Lmeta{options}\verb|]{|\Lmeta{filename}\verb|}{|\Lmeta{obabel options}\verb|}| \\
+\verb|\chemobabel*[|\Lmeta{options}\verb|]{|\Lmeta{filename}\verb|}|
\end{center}
%<*en>
-As parameters, \textit{filename} should be placed in the first braces, and
-\textit{obabel options} (see Section \ref{depict} for some examples)
-can be added in the second braces.
-You can leave the second parameter empty.
-
-You can give \textit{options} to be passed to \verb|\includegraphics|
-command as optional parameters in the box brackets.
-This option is not necessary, so can be omitted. In this case the default
-option ``scale=1" is passed to \verb|\includegraphics| command.
+\verb|\chemobabel| takes one optional parameter and two mandatory parameters.
+\begin{itemize}
+ \item The optional parameter \Lmeta{options} in the box brackets
+ is passed to \verb|\includegraphics|.
+ If omitted, the default ``scale=1' is assumed.
+ \item The first mandatory parameter \Lmeta{filename} is the file name
+ which contains chemical structural formula.
+ \item The second mandatory parameter \Lmeta{obabel options}
+ is passed to \verb|obabel| command
+ (see Section \ref{depict} for some examples).
+\end{itemize}
+If you want to leave the second parameter empty,
+a shorthand form \verb|\chemobabel*| is also available
+(since \Lver{v0.9k [2022/10/09]}).
%</en>
%<*ja>
-引数として,中括弧の1つめにファイル名を与え,2つめにobabelに送る
-オプション(例は第\ref{depict}節を参照)を指定してください。
-2つめの引数は空にすることもできます。
-
-また,オプションとして角括弧に \verb|\includegraphics| に渡すオプションを
-指定することができます。
-このオプションは省略可能で,何も指定しない場合は scale=1 が適用されます。
+\verb|\chemobabel| は1つのオプション引数と2つの必須引数をとります。
+\begin{itemize}
+ \item 角括弧内のオプション引数は \verb|\includegraphics| に渡されます。
+ 省略された場合は \verb|scale=1| とみなされます。
+ \item 必須引数の1つめには化学構造式が描かれたファイル名を与えます。
+ \item 必須引数の2つめには \verb|obabel| に送るオプション
+ (例は第\ref{depict}節を参照)を指定します。
+\end{itemize}
+必須引数の2つめを空にしたい場合は,
+短縮形として \verb|\chemobabel*| を使用することもできます
+(\Lver{v0.9k [2022/10/09]}以降)。
%</ja>
%<*en>
@@ -488,7 +504,7 @@ Use \verb|\smilesobabel| command as follows:
\begin{verbatim}
\smilesobabel{CCO}{}
-\smilesobabel[width=35mm]{CC(=O)Nc1ccc(cc1)O}{}
+\smilesobabel*[width=25mm]{CC(=O)Nc1ccc(cc1)O}
\end{verbatim}
%<*en>
@@ -511,18 +527,19 @@ $ dvipdfmx test.dvi
\begin{figure}[h]
\centering
\smilesobabel{CCO}{} \quad
- \smilesobabel[width=25mm]{CC(=O)Nc1ccc(cc1)O}{}
+ \smilesobabel*[width=25mm]{CC(=O)Nc1ccc(cc1)O}
\caption{Conversion from SMILES notation}\label{fig:smi1}
\end{figure}
%<en>The syntax is:
%<ja>構文は以下のとおりです。
\begin{center}
-\verb|\smilesobabel[|\textit{options}\verb|]{|\textit{SMILES notation}\verb|}{|\textit{obabel options}\verb|}|
+\verb|\smilesobabel[|\Lmeta{options}\verb|]{|\Lmeta{SMILES notation}\verb|}{|\Lmeta{obabel options}\verb|}| \\
+\verb|\smilesobabel*[|\Lmeta{options}\verb|]{|\Lmeta{SMILES notation}\verb|}|
\end{center}
%<*en>
The only difference from \verb|\chemobabel| is that
-\textit{SMILES notation} should be placed in the first braces.
+\Lmeta{SMILES notation} should be placed in the first braces.
You can put any kinds of SMILES notations in parameters of
\verb|\smilesobabel|, even when they contain some special characters
such as a backslash (\verb|\|) and a percent symbol (\verb|%|).
@@ -539,26 +556,25 @@ these special characters.
特別な文字を含むことができる設計になっています。
%</ja>
\begin{verbatim}
-\smilesobabel[width=28mm]{Cl/C=C/Br}{}
-\smilesobabel[width=28mm]{Cl/C=C\Br}{}
+\smilesobabel*[width=28mm]{Cl/C=C/Br}
+\smilesobabel*[width=28mm]{Cl/C=C\Br}
\end{verbatim}
\begin{figure}[h]
\centering
- \smilesobabel[width=28mm]{Cl/C=C/Br}{} \quad
- \smilesobabel[width=28mm]{Cl/C=C\Br}{}
+ \smilesobabel*[width=28mm]{Cl/C=C/Br} \quad
+ \smilesobabel*[width=28mm]{Cl/C=C\Br}
\end{figure}
%<*en>
-\noindent \textbf{Notes for users of earlier versions} ($\le$ \textsf{chemobabel} v0.6 [2015/06/29])
+\noindent \textbf{Notes for users of earlier versions \Lver{v0.6 [2015/06/29]} or older}
-In earlier versions of \textsf{chemobabel}, it was necessary for users
+In earlier versions of \Lpack{chemobabel}, it was necessary for users
to pay another attention when using these \LaTeX\ special characters.
However, the workaround I had suggested before was far from desirable
because ``casual \LaTeX\ users'' were forced to change category codes
of these characters manually.
-To solve this problem, I prepared supporting macros inside the package
-itself ($\ge$ \textsf{chemobabel} v0.7 [2015/08/26]).
+To solve this problem, I improved the internal macros since \Lver{v0.7 [2015/08/26]}.
Now you can put any kinds of SMILES notations directly without worrying
about special characters (\verb|\|, \verb|%|, etc).
Note that the undesirable workaround (like changing \verb|\catcode| inside
@@ -566,15 +582,15 @@ Note that the undesirable workaround (like changing \verb|\catcode| inside
%</en>
%<*ja>
-\noindent \textbf{旧バージョンのユーザに対する注意} ($\le$ \textsf{chemobabel} v0.6 [2015/06/29])
+\noindent \textbf{\Lver{v0.6 [2015/06/29]}以前の旧バージョンのユーザに対する注意}
-古いバージョンの\textsf{chemobabel}では,
+古いバージョンの\Lpack{chemobabel}では,
これらの\LaTeX で特別な意味を持つ文字に注意を払う必要がありました。
従来私が紹介してきた回避策は“カジュアルな \LaTeX ユーザ”に
カテゴリーコードを手動で変更させていたため,好ましいものではありませんでした。
-この問題を解決するため,パッケージ本体の側でこれらの文字をサポートする
-マクロを組み込みました(\textsf{chemobabel} v0.7 [2015/08/26] 以降)。
+この問題を解決するため,\Lver{v0.7 [2015/08/26]}以降では
+パッケージ本体の側でこれらの文字をサポートするように改良を施しました。
これにより,\verb|\| や \verb|%| といった特別な文字を心配することなく,
任意のSMILES表記を直接引数に渡すことができるようになっています。
従来の回避策(\verb|\begingroup| ... \verb|\endgroup| 内で \verb|\catcode| を
@@ -591,16 +607,16 @@ Note that the undesirable workaround (like changing \verb|\catcode| inside
%</ja>
%<*en>
-By default, \textsf{chemobabel} converts chemical structures into
+By default, \Lpack{chemobabel} converts chemical structures into
PDF images using Inkscape. However, you can switch the image format
and the conversion program if you like.
When you are using drivers which do not support PDF figures (such as dvips),
-it will be helpful if \textsf{chemobabel} converts them into EPS images.
+it will be helpful if \Lpack{chemobabel} converts them into EPS images.
For this purpose, you can use:
%</en>
%<*ja>
-\textsf{chemobabel} パッケージは,デフォルトでは化学構造式をInkscapeによって
+\Lpack{chemobabel} パッケージは,デフォルトでは化学構造式をInkscapeによって
PDF形式の画像ファイルに変換して文書中に取り込みます。
しかし,オプションで画像形式と変換プログラムを変更することができます。
@@ -612,19 +628,19 @@ dvipsなどのPDF非対応のドライバを使用する場合は,EPS形式の
\end{verbatim}
%<*en>
The option \verb|eps| switches the image format (that is, output format
-from Inkscape) into EPS ($\ge$ \textsf{chemobabel} v0.9d [2016/02/28]).
+from Inkscape) into EPS (since \Lver{v0.9d [2016/02/28]}).
You can also change the image conversion program from ``Inkscape'' to
-``rsvg-convert'' ($\ge$ \textsf{chemobabel} v0.9e [2016/03/07]).
+``rsvg-convert'' (since \Lver{v0.9e [2016/03/07]}).
The program rsvg-convert is faster than inkscape, so it will be useful.
For this purpose, use \verb|librsvg| option:
%</en>
%<*ja>
というように \verb|eps| オプションを指定すれば,内部でInkscapeから出力される
-画像形式をPDFではなくEPSに変更します(\textsf{chemobabel} v0.9d [2016/02/28] 以降)。
+画像形式をPDFではなくEPSに変更します(\Lver{v0.9d [2016/02/28]}以降)。
また,画像変換プログラムを Inkscape から rsvg-convert に変更することもできます
-(\textsf{chemobabel} v0.9e [2016/03/07] 以降)。
+(\Lver{v0.9e [2016/03/07]}以降)。
rsvg-convertはInkscapeより高速ですから,便利かもしれません。
この場合は,以下のように \verb|librsvg| オプションを指定します。
%</ja>
@@ -646,13 +662,13 @@ The default behavior is equivalent to the \verb|pdf| and \verb|inkscape| options
Moreover, Open Babel v2.4.0 or later versions generate images with
a rather large margin. To avoid this, the images are cropped
using \verb|pdfcrop| for PDF or \verb|ps2eps| for EPS
-($\ge$ \textsf{chemobabel} v0.9i [2022/09/12]).
+(since \Lver{v0.9i [2022/09/12]}).
If you want to disable this cropping, please add \verb|nocrop| option:
%</en>
%<*ja>
さらに,Open Babel v2.4.0以降で生成される画像はデフォルトで余白が大きいため,
\verb|pdfcrop|(PDFの場合)あるいは\verb|ps2eps|(EPSの場合)で
-クロップしています(\textsf{chemobabel} v0.9i [2022/09/12] 以降)。
+クロップしています(\Lver{v0.9i [2022/09/12]}以降)。
これをやめたい場合は \verb|nocrop| オプションを指定してください。
%</ja>
\begin{verbatim}
@@ -704,7 +720,7 @@ When typesetting, usual command
$ pdflatex test.tex
\end{verbatim}
can be used.
-With \verb|extract| option, all \textsf{chemobabel} does is extracting
+With \verb|extract| option, all \Lpack{chemobabel} does is extracting
all \verb|\chemobabel| and \verb|\smilesobabel| commands from the
original \LaTeX\ file.
You will get ``ChemFigFile.tex'' in the same directory, a minimal
@@ -718,7 +734,7 @@ You can simply typeset it by
$ platex test.tex
\end{verbatim}
というコマンドを使います。
-\verb|extract| オプションを付けると,\textsf{chemobabel}パッケージは
+\verb|extract| オプションを付けると,\Lpack{chemobabel}パッケージは
単に元の\LaTeX ソースから \verb|\chemobabel| と \verb|\smilesobabel| コマンド
だけを抽出するはたらきをします。
その結果,同じディレクトリに「ChemFigFile.tex」というファイルが生成します。
@@ -730,9 +746,9 @@ $ pdflatex -shell-escape ChemFigFile.tex
\end{verbatim}
%<*ja>
欧文と同じ仕様に統一したため,抽出される「ChemFigFile.tex」では
-\textsf{graphicx}パッケージに \texttt{[dvipdfmx]} オプション
+\Lpack{graphicx}パッケージに \verb+[dvipdfmx]+ オプション
を与えずに読み込んでいます。したがって,
-このタイプセットだけは\texttt{pdflatex}を用いてください。
+このタイプセットだけは\Lcode{pdflatex}を用いてください。
%</ja>
%<*en>
and you will get PDF figures in the same way
@@ -776,12 +792,12 @@ $ dvipdfmx test.dvi
%<*en>
As I have already mentioned, in both \verb|\chemobabel| and \verb|\smilesobabel|,
-you can give some \textit{obabel options} in the second braces.
+you can give some \Lmeta{obabel options} in the second braces.
Here I will introduce some examples.
%</en>
%<*ja>
既に述べたとおり,\verb|\chemobabel| と \verb|\smilesobabel| の両方について,
-2つめの中括弧に \textit{obabel options} を与えることができます。
+2つめの中括弧に \Lmeta{obabel options} を与えることができます。
ここで,いくつかの有用な例を挙げておきます。
%</ja>
\begin{itemize}
@@ -807,8 +823,8 @@ $ obabel -:"CC(=O)Nc1ccc(cc1)O" -O smilesobabelimg[NUM].svg -xu -xC
\begin{verbatim}
\chemobabel{ATP.cdx}{-xd}
\end{verbatim}
-%<en>You can add \texttt{-xd} option to remove filenames from ChemDraw figures with Open Babel 2.x.
-%<ja>Open Babel 2.x系列でChemDrawの図からファイル名を取り除くには,\texttt{-xd} オプションを付けます:
+%<en>You can add \Lcode{-xd} option to remove filenames from ChemDraw figures with Open Babel 2.x.
+%<ja>Open Babel 2.x系列でChemDrawの図からファイル名を取り除くには,\Lcode{-xd} オプションを付けます:
\begin{verbatim}
$ obabel -:"ATP.cdx" -O chemobabelimg[NUM].svg -xd
\end{verbatim}
@@ -819,7 +835,7 @@ $ obabel -:"ATP.cdx" -O chemobabelimg[NUM].svg -xd
\smilesobabel[width=21mm]{CC(=O)Nc1ccc(cc1)O}{} \hspace{1cm}
\smilesobabel[width=25mm]{CC(=O)Nc1ccc(cc1)O}{-xa} \hspace{1cm}
\smilesobabel[width=21mm]{CC(=O)Nc1ccc(cc1)O}{-xu}
- \caption{Acetaminophen (Paracetamol): Nothing, \texttt{-xa}, \texttt{-xu}}
+ \caption{Acetaminophen (Paracetamol): Nothing, \Lcode{-xa}, \Lcode{-xu}}
SMILES: \verb|CC(=O)Nc1ccc(cc1)O|
\end{figure}
@@ -828,7 +844,7 @@ $ obabel -:"ATP.cdx" -O chemobabelimg[NUM].svg -xd
\smilesobabel[width=25mm]{C1[C@H](C)C[C@@H](O)C1}{} \hspace{1cm}
\smilesobabel[width=25mm]{C1[C@H](C)C[C@@H](O)C1}{-xC} \hspace{1cm}
\smilesobabel[width=25mm]{C1[C@H](C)C[C@@H](O)C1}{-xt}
- \caption{(1\textit{S},3\textit{S})-3-Methylcyclopentanol: Nothing, \texttt{-xC}, \texttt{-xt}}
+ \caption{(1\textit{S},3\textit{S})-3-Methylcyclopentanol: Nothing, \Lcode{-xC}, \Lcode{-xt}}
SMILES: \verb|C1[C@H](C)C[C@@H](O)C1|
\end{figure}
@@ -837,7 +853,7 @@ $ obabel -:"ATP.cdx" -O chemobabelimg[NUM].svg -xd
\smilesobabel[width=42mm]{CCc1cccc(c1)C(=O)Cl}{} \hspace{1cm}
\smilesobabel[width=42mm]{CCc1cccc(c1)C(=O)Cl}{-xa -xu} \hspace{1cm}
\smilesobabel[width=42mm]{CCc1cccc(c1)C(=O)Cl}{-xu -xC}
- \caption{3-Ethylbenzoyl chloride: Nothing, \texttt{-xa -xu}, \texttt{-xu -xC}}
+ \caption{3-Ethylbenzoyl chloride: Nothing, \Lcode{-xa -xu}, \Lcode{-xu -xC}}
SMILES: \verb|CCc1cccc(c1)C(=O)Cl|
\end{figure}
@@ -845,7 +861,7 @@ $ obabel -:"ATP.cdx" -O chemobabelimg[NUM].svg -xd
\centering
\smilesobabel[width=42mm]{CCc1cccc(c1)C(=O)Cl}{--highlight "cC=O blue"} \hspace{1cm}
\smilesobabel[width=42mm]{CCc1cccc(c1)C(=O)Cl}{-xA --genalias}
- \caption{3-Ethylbenzoyl chloride: \texttt{--highlight "cC=O blue"}, \texttt{-xA --genalias}}
+ \caption{3-Ethylbenzoyl chloride: \Lcode{--highlight "cC=O blue"}, \Lcode{-xA --genalias}}
SMILES: \verb|CCc1cccc(c1)C(=O)Cl|
\end{figure}
@@ -853,14 +869,14 @@ $ obabel -:"ATP.cdx" -O chemobabelimg[NUM].svg -xd
\centering
\chemobabel[width=65mm]{draw/Firefly luciferin.mol}{} \hspace{1cm}
\chemobabel[width=65mm]{draw/Firefly luciferin.mol}{-xa}
- \caption{Firefly luciferin (from MDL Molfiles): Nothing, \texttt{-xa}}
+ \caption{Firefly luciferin (from MDL Molfiles): Nothing, \Lcode{-xa}}
\end{figure}
\begin{figure}[ht]
\centering
\chemobabel[width=70mm]{draw/ATP.cdx}{} \hspace{1cm}
\chemobabel[width=70mm]{draw/ATP.cdx}{-xd}
- \caption{ATP (from ChemDraw files): Nothing, \texttt{-xd}}
+ \caption{ATP (from ChemDraw files): Nothing, \Lcode{-xd}}
\end{figure}
\begin{figure}[ht]
@@ -897,14 +913,14 @@ Open BabelはSMILES表記から複雑な構造式を生成することができ
\begin{figure}[ht]
\centering
- \smilesobabel[width=55mm]{CN1CC[C@]23c4c5ccc(c4O[C@H]2[C@H](C=C[C@H]3[C@H]1C5)O)O}{}
+ \smilesobabel*[width=55mm]{CN1CC[C@]23c4c5ccc(c4O[C@H]2[C@H](C=C[C@H]3[C@H]1C5)O)O}
\caption{($-$)-Morphine}
SMILES: \verb|CN1CC[C@]23c4c5ccc(c4O[C@H]2[C@H](C=C[C@H]3[C@H]1C5)O)O|
\end{figure}
\begin{figure}[ht]
\centering
- \smilesobabel[width=150mm]{C[C@@H]1C[C@H]2[C@@H](CC(=O)O2)O[C@H]3C[C@@H]4[C@H](C[C@@H]([C@@H]5[C@@H](O4)C/C=C\C[C@@H]6[C@@H](O5)C/C=C\[C@@H]7[C@@H](O6)CCC[C@@H]8[C@@](O7)(C[C@@H]9[C@@H](O8)C[C@@H]2[C@@H](O9)[C@H](C[C@H](O2)CC(=C)C=O)O)C)C)O[C@@]3(C1)C}{}
+ \smilesobabel*[width=150mm]{C[C@@H]1C[C@H]2[C@@H](CC(=O)O2)O[C@H]3C[C@@H]4[C@H](C[C@@H]([C@@H]5[C@@H](O4)C/C=C\C[C@@H]6[C@@H](O5)C/C=C\[C@@H]7[C@@H](O6)CCC[C@@H]8[C@@](O7)(C[C@@H]9[C@@H](O8)C[C@@H]2[C@@H](O9)[C@H](C[C@H](O2)CC(=C)C=O)O)C)C)O[C@@]3(C1)C}
\caption{Brevetoxin A}
SMILES (Sorry but too long): \verb|C[C@@H]1C[C@H]2[C@@H](CC(=O)O2)O[C@H]3C[C@@H]4[C@H](C[C@@H]([C@@H]5[C@@H](O4)C/C=C\C[C@@H]6[C@@H](O5)C/C=C\[C@@H]7[C@@H](O6)CCC[C@@H]8[C@@](O7)(C[C@@H]9[C@@H](O8)C[C@@H]2[C@@H](O9)[C@H](C[C@H](O2)CC(=C)C=O)O)C)C)O[C@@]3(C1)C|
\end{figure}
@@ -939,10 +955,10 @@ Sesamin: \verb|c1cc2c(cc1C3C4COC(C4CO3)c5ccc6c(c5)OCO6)OCO2|
\centering
\includegraphics[scale=0.5]{figures/Mac231-sesamin-normal.pdf}
\includegraphics[scale=0.5]{figures/Mac231-sesamin-gen2d.pdf}
- \caption{Sesamin (figures from Open Babel for Mac 2.3.1; Normal and \texttt{--gen2d})}
+ \caption{Sesamin (figures from Open Babel for Mac 2.3.1; Normal and \Lcode{--gen2d})}
\includegraphics[scale=0.5]{figures/Win232-sesamin-normal.pdf}
\includegraphics[scale=0.5]{figures/Win232-sesamin-gen2d.pdf}
- \caption{Sesamin (figures from Open Babel for Win 2.3.2; Normal and \texttt{--gen2d})}
+ \caption{Sesamin (figures from Open Babel for Win 2.3.2; Normal and \Lcode{--gen2d})}
\end{center}
\end{figure}
@@ -963,7 +979,7 @@ Here we can see the formula generated from a SMILES notation lacks one double bo
\caption{Firefly luciferin: exact structure from ChemSpider ID 4588411}
\includegraphics[scale=0.6]{figures/Win232-FireflyLuciferin.pdf}
\caption{Firefly luciferin?: output from Open Babel for Win 2.3.2}
- \smilesobabel[width=66mm]{C1[C@@H](N/C(=c\2/nc3c(=CC(=O)C=C3)s2)/S1)C(=O)O}{}
+ \smilesobabel*[width=66mm]{C1[C@@H](N/C(=c\2/nc3c(=CC(=O)C=C3)s2)/S1)C(=O)O}
\caption{Firefly luciferin?: output from current Open Babel}
SMILES: \verb|C1[C@@H](N/C(=c\2/nc3c(=CC(=O)C=C3)s2)/S1)C(=O)O|
\end{figure}
@@ -991,24 +1007,24 @@ only one character string is very interesting, isn't it?
%</ja>
%<*en>
-\subsection{Advantages of \textsf{chemobabel}}
+\subsection{Advantages of \Lpack{chemobabel}}
%</en>
%<*ja>
-\subsection{\textsf{chemobabel}パッケージの有利な点}
+\subsection{\Lpack{chemobabel}パッケージの有利な点}
%</ja>
%<*en>
The macros \verb|\smiles| (written by Noel O'Boyle \cite{NOB1}) and
-\verb|\obabel| (depends on \textsf{graphvizObabel.sty} by
+\verb|\obabel| (depends on \Lpack{graphvizObabel.sty} by
Jakob Lykke Andersen's \cite{JLA}) can be used as follows:
%</en>
%<*ja>
Noel O'Boyleさんによる \verb|\smiles| \cite{NOB1} あるいは
-Jakob Lykke Andersenさんによる\textsf{graphvizObabel.sty}が
+Jakob Lykke Andersenさんによる\Lpack{graphvizObabel.sty}が
提供する \verb+\obabel+ \cite{JLA} は以下のようにして使うことになっています:
%</ja>
\begin{verbatim}
-% ----- for \smiles command -----
+%% ----- for \smiles command -----
\newcounter{smilescounter}
\setcounter{smilescounter}{1}
\newcommand{\smiles}[1]{
@@ -1016,11 +1032,16 @@ Jakob Lykke Andersenさんによる\textsf{graphvizObabel.sty}が
\includegraphics{smilesimg\arabic{smilescounter}.png}
\addtocounter{smilescounter}{1}
}
-% ----- for \obabel command -----
-\usepackage{graphvizObabel}
-% ============ usage ============
+ ...
\smiles{CCO}
+%% -----
+\end{verbatim}
+\begin{verbatim}
+%% ----- for \obabel command -----
+\usepackage{graphvizObabel}
+ ...
\obabel[scale=0.6]{CCO}
+%% -----
\end{verbatim}
%<*en>
However, \verb|\smiles| command creates raster graphics (.png) and
@@ -1055,7 +1076,7 @@ Also, computer-generated formulas may sometimes be unnatural and undesirable.
Therefore this method will be useful only when you need a simple method
for inserting structural formulas with minimal modification.
If you are not satisfied with the output, consider using {\XyMTeX} or
-\textsf{chemfig} packages instead.
+\Lpack{chemfig} packages instead.
I also found following packages which can be used for similar purpose:
%</en>
@@ -1068,16 +1089,16 @@ I also found following packages which can be used for similar purpose:
好ましくない場合もあるかもしれません。
したがって,この方法は構造式の出力を完全に制御したいという意図がなく,
構造式を簡便に挿入したい場合にのみ役に立つでしょう。
-出力に満足できない場合は,\XyMTeX や\textsf{chemfig}のようなパッケージを
+出力に満足できない場合は,\XyMTeX や\Lpack{chemfig}のようなパッケージを
代わりに使うことをご検討ください。
同様の目的を達成するために使えそうなパッケージとして,
以下のようなものもあります:
%</ja>
\begin{itemize}
- \item \href{http://www.ctan.org/pkg/mol2chemfig}{\textsf{mol2chemfig}}:
+ \item \href{http://www.ctan.org/pkg/mol2chemfig}{\Lpack{mol2chemfig}}:
convert chemical structures from MDL molfile format
- to \textsf{chemfig} source code
+ to \Lpack{chemfig} source code
\end{itemize}
\clearpage
@@ -1126,7 +1147,7 @@ It is important to prevent these characters from being translated as
\LaTeX\ special characters.
However, a backslash (\verb|\|) is a default escape character in \LaTeX,
and a percent symbol (\verb|%|) also has a special meaning as a comment character.
-In \textsf{chemobabel} (higher than v0.7), all these characters are
+In \Lpack{chemobabel} (higher than v0.7), all these characters are
handled properly by changing category codes temporarily (like \verb+\verb+). \\
%</en>
%<*ja>
@@ -1134,18 +1155,12 @@ handled properly by changing category codes temporarily (like \verb+\verb+). \\
必要がありますが,バックスラッシュ \verb|\| はデフォルトの
エスケープ文字であり,またパーセント記号 \verb|%| もコメント文字と
しての特殊な意味を持っています。
-\textsf{chemobabel} v0.7以上では,カテゴリーコードを一時的に変更することで
+\Lpack{chemobabel} v0.7以上では,カテゴリーコードを一時的に変更することで
これらすべての文字を適切に扱うようになっています(\verb+\verb+と同様の手法)。
%</ja>
\clearpage
-To do (if possible):
-\begin{itemize}
-\item Check whether \texttt{obabel} and \texttt{inkscape} are successfully
-installed or not, before running programs.
-\end{itemize}
-
%<*en>
\section{Version History}
%</en>
@@ -1156,10 +1171,10 @@ installed or not, before running programs.
\begin{table}[h]
\centering
\begin{tabular}{ll}
-2014/12/01 v0.1 & Made public as \textsf{smilesobabel.sty} \\
+2014/12/01 v0.1 & Made public as \Lpack{smilesobabel.sty} \\
2014/12/02 v0.2 & Add options which can be passed to obabel. \\
-2014/12/07 v0.3 & Change name of package: \textsf{chemobabel.sty} \\
- & Images are stored in \texttt{chemobabelimgdir}. \\
+2014/12/07 v0.3 & Change name of package: \Lpack{chemobabel.sty} \\
+ & Images are stored in \Lcode{chemobabelimgdir}. \\
& Add \verb|\chemobabel| command. \\
2014/12/09 v0.4 & Fix a bug: (Thanks: Yusuke Terada) \\
& Extra spaces at the end of lines are removed. \\
@@ -1179,13 +1194,17 @@ installed or not, before running programs.
2022/09/11 v0.9h & Support Inkscape version 1.0 command line syntax. \\
2022/09/12 v0.9i & Crop images before inclusion, add \verb|nocrop| option. \\
2022/09/19 v0.9j & Check shell-escape status to show better error message. \\
+ & This is the first release on CTAN! \\
+2022/10/09 v0.9k & Add \verb|\chemobabel*| and \verb|\smilesobabel*|. \\
+ & Warn if a user need to run another \LaTeX. \\
+ & Improve \verb|[extract]| to take over user-given package options. \\
\end{tabular}
\end{table}
\textbf{Important!}
\begin{itemize}
\item In Version 0.2, the number of parameters set in \verb|\smilesobabel| is changed!
-\item From Version 0.3, the package name is changed to \textsf{chemobabel.sty}.
+\item From Version 0.3, the package name is changed to \Lpack{chemobabel.sty}.
\item From Version 0.7, the \verb|\catcode|-related workaround is rather harmful.
\end{itemize}
diff --git a/graphics/chemobabel/chemobabel.sty b/graphics/chemobabel/chemobabel.sty
index 4f3122bb37..070effec11 100644
--- a/graphics/chemobabel/chemobabel.sty
+++ b/graphics/chemobabel/chemobabel.sty
@@ -17,7 +17,7 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{chemobabel}
- [2022/09/19 v0.9j Chemical structures with Open Babel]
+ [2022/10/09 v0.9k Chemical structures with Open Babel]
%% Start of package main code
%% Thanks: http://imada.sdu.dk/~jlandersen/latex/graphvizObabel.sty
@@ -25,6 +25,9 @@
\RequirePackage{verbatim}
\RequirePackage{graphicx}
+%% ----- Check status -----
+\chardef\chemob@bel@status\z@
+
%% ----- External command execution -----
\ifx\directlua\@undefined
\def\chemob@bel@exec#1{\immediate\write18{#1}}
@@ -44,6 +47,17 @@
\chardef\chemob@bel@shellescape =\directlua{tex.sprint(status.shell_escape)}
\fi
+%% ----- Ensure -shell-escape when processing ChemFigFile.tex
+\edef\chemob@bel@jobname{\jobname}
+{\escapechar=-1 \xdef\chemob@bel@outname{\string\ChemFigFile}}
+\ifx\chemob@bel@jobname\chemob@bel@outname
+ \ifnum\chemob@bel@shellescape=\@ne\else
+ \PackageError{chemobabel}{%
+ Processing \chemob@bel@outname.tex needs -shell-escape.\MessageBreak
+ Run 'pdflatex -shell-escape \chemob@bel@outname.tex'}\@ehc
+ \fi
+\fi
+
%% ----- Make a directory for images -----
\newcommand\chemobabelimgdir{chemobabelimgdir}
\chemob@bel@exec{mkdir \chemobabelimgdir}
@@ -98,6 +112,7 @@
No log file.%
}%
\end{minipage}}%
+ \global\chardef\chemob@bel@status\@ne
}%
}
%% ----- Common part of \smilesobabel and \chemobabel end -----
@@ -111,14 +126,28 @@
% 1: (optional) options for includegraphics
% 2: SMILES notation
% 3: options for obabel
-\newcommand\smilesobabel[1][scale=1]{%
+\newcommand\smilesobabel{\@ifstar{\smilesobabel@i}{\smilesobabel@ii}}
+\newcommand\smilesobabel@i[1][scale=1]{%
\def\smilesobabel@next{\includegraphics[#1]}%
\begingroup
\let\do\@makeother \dospecials \catcode`\{=1 \catcode`\}=2
- \@smilesobabel
+ \@smilesobabel@i
}
-\newcommand\@smilesobabel[2]{%
+\newcommand\smilesobabel@ii[1][scale=1]{%
+ \def\smilesobabel@next{\includegraphics[#1]}%
+ \begingroup
+ \let\do\@makeother \dospecials \catcode`\{=1 \catcode`\}=2
+ \@smilesobabel@ii
+}
+\def\@smilesobabel@i#1{%
+ \endgroup
+ \@smilesobabel@main{#1}{}%
+}
+\def\@smilesobabel@ii#1#2{%
\endgroup
+ \@smilesobabel@main{#1}{#2}%
+}
+\def\@smilesobabel@main#1#2{%
\chemob@bel@exec{%
\smilesob@bel@obabelcmd{#1}{#2} 2>\smilesob@belGetName.log
&& \chemob@bel@svgtoimgcmd{\smilesob@belGetName}{\chemob@belimgExt} 2>>\smilesob@belGetName.log
@@ -138,14 +167,28 @@
% 1: (optional) options for includegraphics
% 2: original files (.mol, .cdx, etc.)
% 3: options for obabel
-\newcommand\chemobabel[1][scale=1]{%
+\newcommand\chemobabel{\@ifstar{\chemobabel@i}{\chemobabel@ii}}
+\newcommand\chemobabel@i[1][scale=1]{%
+ \def\chemobabel@next{\includegraphics[#1]}%
+ \begingroup
+ \let\do\@makeother \dospecials \catcode`\{=1 \catcode`\}=2
+ \@chemobabel@i
+}
+\newcommand\chemobabel@ii[1][scale=1]{%
\def\chemobabel@next{\includegraphics[#1]}%
\begingroup
\let\do\@makeother \dospecials \catcode`\{=1 \catcode`\}=2
- \@chemobabel
+ \@chemobabel@ii
+}
+\def\@chemobabel@i#1{%
+ \endgroup
+ \@chemobabel@main{#1}{}%
}
-\newcommand\@chemobabel[2]{%
+\def\@chemobabel@ii#1#2{%
\endgroup
+ \@chemobabel@main{#1}{#2}%
+}
+\def\@chemobabel@main#1#2{%
\IfFileExists{"#1"}{%
% the file exists: start processing
% (``#1'' can contain spaces, so ``"'' required)
@@ -157,7 +200,7 @@
\chemob@bel@common@maybeimg{\chemobabel@next}{\chemob@belGetName}{file ``#1''}%
}{%
% the file does not exist: show a std error
- \PackageError{chemobabel}{File ``#1'' not found}{}%
+ \PackageError{chemobabel}{File ``#1'' not found}\@ehc
\fbox{\begin{minipage}{0.9\textwidth}
Error in chemobabel: the file ``#1'' does not exist.
\end{minipage}}%
@@ -201,67 +244,180 @@
\DeclareOption{librsvg}%
{\let\chemob@bel@svgtoimgcmd\chemob@bel@librsvgcmd}
% crop image or not
-\DeclareOption{nocrop}{%
- \let\chemob@bel@cropcmd\@gobble
- \let\chemob@bel@maybecrop\@empty}
+\let\chemob@bel@nocrop\relax
+\DeclareOption{nocrop}{\let\chemob@bel@nocrop\@empty}
% default settings
\ExecuteOptions{pdf,inkscape}
-\ProcessOptions\relax
+% handle user settings - arbitrary order allowed
+\ProcessOptions*\relax
+\ifx\chemob@bel@nocrop\relax \else
+ \let\chemob@bel@cropcmd\@gobble
+ \let\chemob@bel@maybecrop\@empty
+\fi
%% ----- Declaration of options end -----
+%% ----- Warn if something went wrong -----
+% e.g.) \chemob@bel@common@maybeimg is not an image
+% --- when current processing failed
+% AND previous shell-escape run not found
+% e.g.) \chemob@bel@common@maybeimg is definitely a wrong image
+% --- when current processing failed
+% BUT previous shell-escape run with different total number found
+% --- note that re-run after removing [extract] should avoid the warning
+% --- as it will include all the correct images from previous shell-escape run
+\def\chemob@bel@record@imgnum#1{%
+ \immediate\write#1{\gdef\string
+ \smilesob@bel@imgNum{\number\value{smilesob@belCounter}}}%
+ \immediate\write#1{\gdef\string
+ \chemob@bel@imgNum{\number\value{chemob@belCounter}}}%
+}
+\def\chemob@bel@preserve@imgnum#1{%
+ \immediate\write#1{\gdef\string
+ \smilesob@bel@imgNum{\smilesob@bel@imgNum}}%
+ \immediate\write#1{\gdef\string
+ \chemob@bel@imgNum{\chemob@bel@imgNum}}%
+}
+\def\chemob@bel@atenddocument{%
+ \ifnum\chemob@bel@status>\z@ % at least one is not an image
+ \PackageWarningNoLine{chemobabel}{%
+ Some processing failed.\MessageBreak
+ Please rerun}%
+ \else % all images
+ \ifnum\chemob@bel@shellescape=\@ne % current run is shell-escape
+ % record number of images of the current run
+ \if@filesw
+ \chemob@bel@record@imgnum{\@mainaux}%
+ \fi
+ % when processing ChemFigFile.tex, also write to the original .aux
+ \ifx\chemob@bel@jobname\chemob@bel@outname
+ \IfFileExists{\chemobabelfile.tex}{%
+ \if@filesw
+ \newwrite\chemob@bel@origaux
+ \immediate\openout\chemob@bel@origaux=\chemobabelfile.aux\relax
+ \chemob@bel@record@imgnum{\chemob@bel@origaux}%
+ \immediate\closeout\chemob@bel@origaux
+ \fi
+ }{}%
+ \fi
+ \else
+ % compare number of images with the previous shell-escape run
+ \ifx\smilesob@bel@imgNum\@undefined\def\smilesob@bel@imgNum{0}\fi
+ \ifnum\value{smilesob@belCounter}=\smilesob@bel@imgNum\relax\else
+ \PackageWarningNoLine{chemobabel}{%
+ Number of \noexpand\smilesobabel changed.\MessageBreak
+ Please rerun}%
+ \fi
+ \ifx\chemob@bel@imgNum\@undefined\def\chemob@bel@imgNum{0}\fi
+ \ifnum\value{chemob@belCounter}=\chemob@bel@imgNum\relax\else
+ \PackageWarningNoLine{chemobabel}{%
+ Number of \noexpand\chemobabel changed.\MessageBreak
+ Please rerun}%
+ \fi
+ % record number of images of the previous shell-escape run
+ \if@filesw
+ \chemob@bel@preserve@imgnum{\@mainaux}%
+ \fi
+ \fi
+ \fi
+}
+\AtEndDocument{\chemob@bel@atenddocument}
+%% ----- Warn if something went wrong end -----
+
%% ----- Exit this package now, if [extract] is not specified -----
\ifx\chemob@bel@extract\relax \endinput \fi
%% Extracting all codes of Open Babel figures
%% Thanks: http://oku.edu.mie-u.ac.jp/tex/mod/forum/discuss.php?d=1411
+%% ----- Safety check before opening output file -----
+\ifx\chemob@bel@jobname\chemob@bel@outname
+ \PackageWarningNoLine{chemobabel}{%
+ Wow! Your file name is `\chemob@bel@outname'!\MessageBreak
+ Option [extract] ignored to avoid overwriting}
+ \expandafter\endinput
+\fi
+
\PackageWarningNoLine{chemobabel}{%
You are using [extract] option.\MessageBreak
No chemical structures will be printed}
+%% ----- Accumulate user-given options to be passed -----
+% the image extension (non-empty)
+\edef\chemob@bel@options{\chemob@belimgExt}
+% image conversion command (except default=inkscape)
+\ifx\chemob@bel@svgtoimgcmd\chemob@bel@inkscapeoldcmd
+ \edef\chemob@bel@options{\chemob@bel@options,inkscape-old}
+\else\ifx\chemob@bel@svgtoimgcmd\chemob@bel@librsvgcmd
+ \edef\chemob@bel@options{\chemob@bel@options,librsvg}
+\fi\fi
+% crop image or not
+\ifx\chemob@bel@nocrop\relax \else
+ \edef\chemob@bel@options{\chemob@bel@options,nocrop}
+\fi
+
%% ----- Define intermediate output file and load packages -----
-\newwrite\ChemFigFile
-\immediate\openout\ChemFigFile=ChemFigFile.tex\relax
-\immediate\write\ChemFigFile{\string\documentclass{article}}
-\immediate\write\ChemFigFile{\string\usepackage{graphicx}}
-\immediate\write\ChemFigFile{\string\usepackage{chemobabel}}
+\newwrite\chemob@bel@outfile
+\immediate\openout\chemob@bel@outfile=\chemob@bel@outname.tex\relax
+\immediate\write\chemob@bel@outfile{\string\def\string\chemobabelfile{\chemob@bel@jobname}}
+\immediate\write\chemob@bel@outfile{\string\documentclass{article}}
+\immediate\write\chemob@bel@outfile{\string\usepackage[\chemob@bel@options]{chemobabel}}
%% ----- Read and write -----
-\immediate\write\ChemFigFile{\string\begin{document}}
-\AtEndDocument{%
- \immediate\write\ChemFigFile{\string\end{document}}%
- \immediate\closeout\ChemFigFile
+\immediate\write\chemob@bel@outfile{\string\begin{document}}
+\def\chemob@bel@atenddocument{%
+ \immediate\write\chemob@bel@outfile{\string\end{document}}%
+ \immediate\closeout\chemob@bel@outfile
\chemob@bel@ifnochem{}{%
\PackageWarningNoLine{chemobabel}{%
Some chemical structures are extracted.\MessageBreak
Run 'pdflatex -shell-escape ChemFigFile.tex'}}%
}
-\renewcommand\smilesobabel{%
+% \smilesobabel*[#1]{#2} => normalized to \smilesobabel[#1]{#2}{#3}
+\renewcommand\smilesobabel@i{%
+ \begingroup
+ \let\do\@makeother \dospecials \catcode`\{=1 \catcode`\}=2
+ \@smilesobabel@i
+}
+\renewcommand\smilesobabel@ii{%
\begingroup
- \let\do\@makeother
- \dospecials
- \catcode`\{=1
- \catcode`\}=2
- \@@smilesobabel
+ \let\do\@makeother \dospecials \catcode`\{=1 \catcode`\}=2
+ \@smilesobabel@ii
}
-\newcommand\@@smilesobabel[3][scale=1]{%
+\renewcommand\@smilesobabel@i[2][scale=1]{%
\endgroup
- \immediate\write\ChemFigFile{%
+ \@smilesobabel@main{#1}{#2}{}%
+}
+\renewcommand\@smilesobabel@ii[3][scale=1]{%
+ \endgroup
+ \@smilesobabel@main{#1}{#2}{#3}%
+}
+\def\@smilesobabel@main#1#2#3{%
+ \immediate\write\chemob@bel@outfile{%
\string\smilesobabel[#1]{#2}{#3}%
\string\newpage}%
[\smilesob@belGetName.\chemob@belimgExt]%
\addtocounter{smilesob@belCounter}{1}}
-\renewcommand\chemobabel{%
+% \chemobabel*[#1]{#2} => normalized to \chemobabel[#1]{#2}{#3}
+\renewcommand\chemobabel@i{%
\begingroup
- \let\do\@makeother
- \dospecials
- \catcode`\{=1
- \catcode`\}=2
- \@@chemobabel
+ \let\do\@makeother \dospecials \catcode`\{=1 \catcode`\}=2
+ \@chemobabel@i
}
-\newcommand\@@chemobabel[3][scale=1]{%
+\renewcommand\chemobabel@ii{%
+ \begingroup
+ \let\do\@makeother \dospecials \catcode`\{=1 \catcode`\}=2
+ \@chemobabel@ii
+}
+\renewcommand\@chemobabel@i[2][scale=1]{%
\endgroup
- \immediate\write\ChemFigFile{%
+ \@chemobabel@main{#1}{#2}{}%
+}
+\renewcommand\@chemobabel@ii[3][scale=1]{%
+ \endgroup
+ \@chemobabel@main{#1}{#2}{#3}%
+}
+\def\@chemobabel@main#1#2#3{%
+ \immediate\write\chemob@bel@outfile{%
\string\chemobabel[#1]{#2}{#3}%
\string\newpage}%
[\chemob@belGetName.\chemob@belimgExt]%
diff --git a/graphics/chemobabel/example-en.tex b/graphics/chemobabel/example-en.tex
index 3f98668adf..86f01f6435 100644
--- a/graphics/chemobabel/example-en.tex
+++ b/graphics/chemobabel/example-en.tex
@@ -15,10 +15,11 @@
\maketitle
The formulas below are generated using \textsf{chemobabel} package with the help of Open Babel and Inkscape.
+% Note: \smilesobabel* and \chemobabel* are provided since 2022-10-09.
\begin{figure}[ht]
\centering
- \smilesobabel{CCO}{}
+ \smilesobabel*{CCO}
\caption{Ethanol}
\end{figure}
@@ -30,8 +31,8 @@ The formulas below are generated using \textsf{chemobabel} package with the help
\begin{figure}[ht]
\centering
- \smilesobabel[scale=0.7]{Cl/C=C/Br}{}
- \smilesobabel[scale=0.7]{Cl/C=C\Br}{}
+ \smilesobabel*[scale=0.7]{Cl/C=C/Br}
+ \smilesobabel*[scale=0.7]{Cl/C=C\Br}
\caption{(\textit{E})-1-bromo-2-chloroethene \& (\textit{Z})-1-bromo-2-chloroethene}
\end{figure}
@@ -43,7 +44,7 @@ The formulas below are generated using \textsf{chemobabel} package with the help
\begin{figure}[ht]
\centering
- \chemobabel[scale=0.4]{draw/Brevetoxin A.mol}{}
+ \chemobabel*[scale=0.4]{draw/Brevetoxin A.mol}
\caption{Brevetoxin A}
\end{figure}
diff --git a/graphics/chemobabel/example-ja.tex b/graphics/chemobabel/example-ja.tex
index c166604975..cc44e109db 100644
--- a/graphics/chemobabel/example-ja.tex
+++ b/graphics/chemobabel/example-ja.tex
@@ -16,10 +16,11 @@
\begin{document}
\maketitle
以下の構造式は、\textsf{chemobabel} パッケージを用いて Open Babel と Inkscape を介した自動変換により生成しました。
+% Note: \smilesobabel* と \chemobabel* は 2022-10-09 で追加されました。
\begin{figure}[ht]
\centering
- \smilesobabel{CCO}{}
+ \smilesobabel*{CCO}
\caption{エタノール}
\end{figure}
@@ -31,8 +32,8 @@
\begin{figure}[ht]
\centering
- \smilesobabel[scale=0.7]{Cl/C=C/Br}{}
- \smilesobabel[scale=0.7]{Cl/C=C\Br}{}
+ \smilesobabel*[scale=0.7]{Cl/C=C/Br}
+ \smilesobabel*[scale=0.7]{Cl/C=C\Br}
\caption{(\textit{E})-1-ブロモ-2-クロロエテンと(\textit{Z})-1-ブロモ-2-クロロエテン}
\end{figure}
@@ -44,7 +45,7 @@
\begin{figure}[ht]
\centering
- \chemobabel[scale=0.4]{draw/Brevetoxin A.mol}{}
+ \chemobabel*[scale=0.4]{draw/Brevetoxin A.mol}
\caption{ブレベトキシンA}
\end{figure}