summaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-10-23 03:01:07 +0000
committerNorbert Preining <norbert@preining.info>2022-10-23 03:01:07 +0000
commit588d4f81788b3a24bd9bd480ec40bb55be4d1da1 (patch)
treea035dd5b60e2cf4afabea9fc6f8a34e5505ba6ac /graphics
parent3183c46c6fe93c96cf342a65ba2ac2b74a14dcbd (diff)
CTAN sync 202210230301
Diffstat (limited to 'graphics')
-rw-r--r--graphics/chemobabel/README.md15
-rw-r--r--graphics/chemobabel/chemobabel-en.pdfbin568562 -> 581582 bytes
-rw-r--r--graphics/chemobabel/chemobabel-ja.pdfbin672338 -> 687975 bytes
-rw-r--r--graphics/chemobabel/chemobabel.dtx104
-rw-r--r--graphics/chemobabel/chemobabel.sty45
5 files changed, 126 insertions, 38 deletions
diff --git a/graphics/chemobabel/README.md b/graphics/chemobabel/README.md
index 397c15cad3..7cd66d5e69 100644
--- a/graphics/chemobabel/README.md
+++ b/graphics/chemobabel/README.md
@@ -7,20 +7,29 @@ ChemDraw files or SMILES notations using Open Babel.
This package offers a new choice for chemists who need
chemical structures in LaTeX documents.
With this package you can insert chemical structural formulas
-into your PDF files easily with the help of Open Babel and Inkscape.
+into your documents easily with the help of Open Babel.
Various chemical formats are allowed for input,
for example, `.cdx`, `.mol` and `.smi`.
## Package Contents
- - chemobabel.sty: Package itself
+ - chemobabel.sty: Package itself; provides `\chemobabel` and `\smilesobabel`
- chemobabel-{en,ja}.pdf: Basic usage (source: chemobabel.dtx)
- example-en.{tex,pdf}: Examples in English
- example-ja.{tex,pdf}: Examples in Japanese
Sample ChemDraw files and MDL Molfiles are also included.
+## Requirements
+
+To use this LaTeX package, it is necessary to enable execution
+of the following external commands via `latex -shell-escape`.
+
+ - `obabel` (Open Babel)
+ - `inkscape` or `rsvg-convert` (for SVG -> PDF/EPS conversion)
+ - `pdfcrop` or `ps2eps` (optional; for cropping large margins of PDF/EPS)
+
## License
This package is distributed under the BSD 2-Clause License.
@@ -43,7 +52,7 @@ This work is based on a lot of resources published online:
## Release Date
-2022-10-09
+2022-10-22
--------------------
Hironobu YAMASHITA (aka. "Acetaminophen" or "@aminophen")
diff --git a/graphics/chemobabel/chemobabel-en.pdf b/graphics/chemobabel/chemobabel-en.pdf
index 381d065821..c4030a44e3 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 f1a7cdc368..b558f4514b 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 2158f591a9..be2ddecfe7 100644
--- a/graphics/chemobabel/chemobabel.dtx
+++ b/graphics/chemobabel/chemobabel.dtx
@@ -17,6 +17,7 @@
\usepackage[nofontspec,defaultsups]{newpxtext}
\usepackage[zerostyle=c,straightquotes]{newtxtt}
\usepackage{newpxmath}
+\usepackage{ascmac}
\usepackage[librsvg]{chemobabel}
\usepackage[bookmarksnumbered=true,hidelinks,%
pdftitle={User Manual for chemobabel.sty},%
@@ -64,17 +65,19 @@ 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
formats}, including MDL Molfiles, ChemDraw files and even from
-SMILES notations, with the help of Open Babel and Inkscape.
-The formulas below are generated using this method.
+SMILES notations, with the help of Open Babel.
+The formulas below are generated using this method.\footnote{Unless
+otherwise noted, this documentation used \Lcode{\input{obversion.txt}}}
日本語版ドキュメントはchemobabel-ja.pdfを参照してください。
%</en>
%<*ja>
この文書では,\textbf{化学構造式を生成}して\LaTeX の文書中に挿入するための
-パッケージである\Lpack{chemobabel.sty}と同梱リソースの使い方を説明します。
+パッケージである\Lpack{chemobabel.sty}の使い方を説明します。
構造式はOpen Babelの機能を利用することにより,MDL Molfile, ChemDrawファイル,
さらにはSMILES表記法を含む\textbf{さまざまな化学データ形式から生成}できます。
-以下の構造式はこの方法によって出力されたものです。
+以下の構造式はこの方法によって出力されたものです\footnote{特に断りがない
+限り,この文書で使用した版は\Lcode{\input{obversion.txt}}です。}。
For English documentation, please refer to chemobabel-en.pdf.
%</ja>
@@ -88,8 +91,8 @@ For English documentation, please refer to chemobabel-en.pdf.
\begin{figure}[ht]
\centering
- \chemobabel[width=90mm]{draw/ATP.cdx}{} \hspace{1cm}
- \chemobabel*[width=35mm]{draw/Glucose.cdx}
+ \chemobabel[width=80mm]{draw/ATP.cdx}{} \hspace{1cm}
+ \chemobabel*[width=30mm]{draw/Glucose.cdx}
\caption{ATP (Adenosine triphosphate) \& Glucose (from ChemDraw files)}
\end{figure}
\begin{center}\small
@@ -121,6 +124,32 @@ becomes wrong.\\ See \url{https://github.com/openbabel/openbabel/issues/338}
%<ja>問い合わせや改善案などはGitHubのIssuesへお願いします。
\end{figure}
+\begin{figure}[ht]
+\centering
+%<en>Also available on CTAN:
+%<ja>CTANからも入手可能です →
+\url{https://www.ctan.org/pkg/chemobabel}\par
+%<en>Distributed with \TeX\ Live and MiK\TeX.
+%<en>Below is a short description for CTAN:\par
+%<ja>\TeX\ LiveやMiK\TeX でも配布されています。
+%<ja>以下はCTANの短い紹介文です。\par
+\begin{screen}
+This package provides a way to convert and include
+chemical structure graphics from various chemical formats,
+such as ChemDraw files, MDL molfile or SMILES notations
+using Open Babel.
+To use this \LaTeX\ package, it is necessary to enable execution
+of the following external commands via \Lcode{latex -shell-escape}.
+\begin{itemize}
+ \item \Lcode{obabel} (Open Babel)
+ \item \Lcode{inkscape} or \Lcode{rsvg-convert}
+ (for SVG -> PDF/EPS conversion)
+ \item \Lcode{pdfcrop} or \Lcode{ps2eps}
+ (optional; for cropping large margins of PDF/EPS)
+\end{itemize}
+\end{screen}
+\end{figure}
+
\clearpage
\setcounter{tocdepth}{3}
\tableofcontents
@@ -206,7 +235,7 @@ 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,
-and \href{https://inkscape.org/en/}{Inkscape} for converting SVG to PDF.
+and \href{https://inkscape.org/en/}{Inkscape} for converting SVG to PDF/EPS.
Both programs are open source and cross-platform, and being actively maintained.
%</en>
%<*ja>
@@ -214,7 +243,8 @@ Both programs are open source and cross-platform, and being actively maintained.
挿入する必要がある化学者に新たな選択肢を提供することでしょう。
この方法では,\href{http://openbabel.org/}{Open Babel}によって
SVG形式の構造式画像を生成し,
-さらに\href{https://inkscape.org/ja/}{Inkscape}によってSVGからPDFに変換します。
+さらに\href{https://inkscape.org/ja/}{Inkscape}によってSVGから
+PDFまたはEPS形式の画像に変換します。
どちらのプログラムもオープンソースかつクロスプラットフォームであり,
盛んに開発が行われています。
%</ja>
@@ -305,16 +335,21 @@ Noel O'Blog の記事\cite{NOB1}, \cite{NOB2}とコメント\cite{JLA}を見つ
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,
+computer, and export PATH to the required command-line programs,
\Lcode{obabel} and \Lcode{inkscape} (or \Lcode{rsvg-convert}).
+The package also uses \Lcode{pdfcrop} (or \Lcode{ps2eps}) to
+crop large margins, but it is included in \TeX\ Live.
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})をインストールし,
-コマンドライン実行ファイルである
-\Lcode{obabel}と\Lcode{inkscape}(または\Lcode{rsvg-convert})にPATHを通します。
+必要なコマンドラインプログラムである
+\Lcode{obabel}と\Lcode{inkscape}(または\Lcode{rsvg-convert})に
+PATHを通します。
+なお,生成画像の大きな余白を切り取るために\Lcode{pdfcrop}(または
+\Lcode{ps2eps})も利用しますが,これは\TeX\ Liveに収録されています。
正しくPATHが通っているかどうかは以下のコマンドによって確認できます:
%</ja>
%<en>In UNIX operating system:
@@ -429,8 +464,9 @@ obabelやinkscapeを呼んで実行できるようになります。
\begin{verbatim}
$ platex -shell-escape test.tex
\end{verbatim}
-すると \verb|chemobabelimgdir| 以下に「chemobabelimg[NUM].pdf」という
-ファイルが生成します。得られたtest.dviに対して
+するとサブディレクトリ \verb|chemobabelimgdir| 以下に
+「chemobabelimg[NUM].pdf」というファイルが生成します。
+得られたtest.dviに対して
\begin{verbatim}
$ dvipdfmx test.dvi
\end{verbatim}
@@ -455,7 +491,7 @@ $ dvipdfmx test.dvi
\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.
+ If omitted, the default ``clip,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}
@@ -470,7 +506,7 @@ a shorthand form \verb|\chemobabel*| is also available
\verb|\chemobabel| は1つのオプション引数と2つの必須引数をとります。
\begin{itemize}
\item 角括弧内のオプション引数は \verb|\includegraphics| に渡されます。
- 省略された場合は \verb|scale=1| とみなされます。
+ 省略された場合は \verb|clip,scale=1| とみなされます。
\item 必須引数の1つめには化学構造式が描かれたファイル名を与えます。
\item 必須引数の2つめには \verb|obabel| に送るオプション
(例は第\ref{depict}節を参照)を指定します。
@@ -627,8 +663,11 @@ dvipsなどのPDF非対応のドライバを使用する場合は,EPS形式の
\usepackage[eps]{chemobabel}
\end{verbatim}
%<*en>
-The option \verb|eps| switches the image format (that is, output format
-from Inkscape) into EPS (since \Lver{v0.9d [2016/02/28]}).
+The option \verb|eps| switches the image format
+(that is, output format from Inkscape) into EPS (since
+\Lver{v0.9d [2016/02/28]}).\footnote{Moreover, since
+\Lver{v0.9l [2022/10/22]}, the package automatically switches to
+EPS mode when using dvips.}
You can also change the image conversion program from ``Inkscape'' to
``rsvg-convert'' (since \Lver{v0.9e [2016/03/07]}).
@@ -637,7 +676,9 @@ For this purpose, use \verb|librsvg| option:
%</en>
%<*ja>
というように \verb|eps| オプションを指定すれば,内部でInkscapeから出力される
-画像形式をPDFではなくEPSに変更します(\Lver{v0.9d [2016/02/28]}以降)。
+画像形式をPDFではなくEPSに変更します(\Lver{v0.9d [2016/02/28]}以降)
+\footnote{\Lver{v0.9l [2022/10/22]}以降ではさらに,dvipsの場合に
+自動的にEPSに切り替えるようにしました。}。
また,画像変換プログラムを Inkscape から rsvg-convert に変更することもできます
(\Lver{v0.9e [2016/03/07]}以降)。
@@ -723,7 +764,7 @@ can be used.
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
+You will get ``ChemFigFile.tex'' in the current directory, a minimal
\LaTeX\ source file which includes all \verb|\chemobabel| and
\verb|\smilesobabel| commands.
You can simply typeset it by
@@ -737,7 +778,7 @@ $ platex test.tex
\verb|extract| オプションを付けると,\Lpack{chemobabel}パッケージは
単に元の\LaTeX ソースから \verb|\chemobabel| と \verb|\smilesobabel| コマンド
だけを抽出するはたらきをします。
-その結果,同じディレクトリに「ChemFigFile.tex」というファイルが生成します。
+その結果,作業ディレクトリに「ChemFigFile.tex」というファイルが生成します。
これは元のソースに書かれていた \verb|\chemobabel| と \verb|\smilesobabel| コマンド
をすべて含む最小の \LaTeX ソースで,これは直接pdflatexでタイプセットできます。
%</ja>
@@ -773,6 +814,27 @@ $ dvipdfmx test.dvi
この方法を用いれば,タイプセットに要する時間を大幅に短縮することも期待できます。
%</ja>
+%<*en>
+\paragraph{Note on the option \Lcode{-output-directory}}
+
+When using the option \Lcode{-output-directory} of \TeX,
+the extracted code ``ChemFigFile.tex'' goes there
+but the subdirectory \verb|chemobabelimgdir| and
+generated images stay in the current working directory.
+To process the resulting files correctly, it would be
+necessary to move files properly.
+%</en>
+%<*ja>
+\paragraph{注意:\Lcode{-output-directory}オプション}
+
+\TeX の\Lcode{-output-directory}オプションを使用すると,
+抽出ファイル「ChemFigFile.tex」はその指定先に書き出されますが,
+サブディレクトリ \verb|chemobabelimgdir| と生成画像は
+現在のディレクトリとなります。
+従って,抽出ファイルと元のファイルを正しく処理するためには
+ファイルを適切に配置する必要があります。
+%</ja>
+
\clearpage
%<*en>
@@ -1198,6 +1260,8 @@ handled properly by changing category codes temporarily (like \verb+\verb+). \\
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. \\
+2022/10/22 v0.9l & Default to EPS mode if PDF inclusion is unsupported by the driver. \\
+ & Default \verb|clip| for image inclusion. \\
\end{tabular}
\end{table}
diff --git a/graphics/chemobabel/chemobabel.sty b/graphics/chemobabel/chemobabel.sty
index 070effec11..be4ecb8af8 100644
--- a/graphics/chemobabel/chemobabel.sty
+++ b/graphics/chemobabel/chemobabel.sty
@@ -17,7 +17,10 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{chemobabel}
- [2022/10/09 v0.9k Chemical structures with Open Babel]
+ [2022/10/22 v0.9l Chemical structures with Open Babel]
+
+\def\chemob@bel@error{\PackageError{chemobabel}}
+\def\chemob@bel@warn{\PackageWarningNoLine{chemobabel}}
%% Start of package main code
%% Thanks: http://imada.sdu.dk/~jlandersen/latex/graphvizObabel.sty
@@ -25,6 +28,18 @@
\RequirePackage{verbatim}
\RequirePackage{graphicx}
+%% ----- Check graphics/x driver -----
+% prefer .pdf but fallback to .eps if necessary
+% --- currently known drivers all support .eps
+\@ifundefined{Gin@rule@.pdf}{\@ifundefined{Gin@rule@.eps}{%
+ \chemob@bel@warn{Unsupported situation? cannot happen}}{}%
+ % EPS: dvips.def
+ \def\chemob@belimgExt@default{eps}%
+}{%
+ % PDF>EPS: dvipdfmx.def, dvisvgm.def, luatex.def, pdftex.def, xetex.def
+ \def\chemob@belimgExt@default{pdf}%
+}
+
%% ----- Check status -----
\chardef\chemob@bel@status\z@
@@ -52,7 +67,7 @@
{\escapechar=-1 \xdef\chemob@bel@outname{\string\ChemFigFile}}
\ifx\chemob@bel@jobname\chemob@bel@outname
\ifnum\chemob@bel@shellescape=\@ne\else
- \PackageError{chemobabel}{%
+ \chemob@bel@error{%
Processing \chemob@bel@outname.tex needs -shell-escape.\MessageBreak
Run 'pdflatex -shell-escape \chemob@bel@outname.tex'}\@ehc
\fi
@@ -85,7 +100,7 @@
\IfFileExists{\chemob@belImgName}{% the image exists: include it
#1{\chemob@belImgName}%
}{% the image was not created - show a warning and a hint
- \PackageWarning{chemobabel}{Processing of #3\space failed}%
+ \chemob@bel@warn{Processing of #3\space failed}%
\fbox{\begin{minipage}{0.9\textwidth}
Warning in chemobabel: #3\space was not processed.
\ifnum\chemob@bel@shellescape=\@ne
@@ -128,13 +143,13 @@
% 3: options for obabel
\newcommand\smilesobabel{\@ifstar{\smilesobabel@i}{\smilesobabel@ii}}
\newcommand\smilesobabel@i[1][scale=1]{%
- \def\smilesobabel@next{\includegraphics[#1]}%
+ \def\smilesobabel@next{\includegraphics[clip,#1]}%
\begingroup
\let\do\@makeother \dospecials \catcode`\{=1 \catcode`\}=2
\@smilesobabel@i
}
\newcommand\smilesobabel@ii[1][scale=1]{%
- \def\smilesobabel@next{\includegraphics[#1]}%
+ \def\smilesobabel@next{\includegraphics[clip,#1]}%
\begingroup
\let\do\@makeother \dospecials \catcode`\{=1 \catcode`\}=2
\@smilesobabel@ii
@@ -169,13 +184,13 @@
% 3: options for obabel
\newcommand\chemobabel{\@ifstar{\chemobabel@i}{\chemobabel@ii}}
\newcommand\chemobabel@i[1][scale=1]{%
- \def\chemobabel@next{\includegraphics[#1]}%
+ \def\chemobabel@next{\includegraphics[clip,#1]}%
\begingroup
\let\do\@makeother \dospecials \catcode`\{=1 \catcode`\}=2
\@chemobabel@i
}
\newcommand\chemobabel@ii[1][scale=1]{%
- \def\chemobabel@next{\includegraphics[#1]}%
+ \def\chemobabel@next{\includegraphics[clip,#1]}%
\begingroup
\let\do\@makeother \dospecials \catcode`\{=1 \catcode`\}=2
\@chemobabel@ii
@@ -200,7 +215,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}\@ehc
+ \chemob@bel@error{File ``#1'' not found}\@ehc
\fbox{\begin{minipage}{0.9\textwidth}
Error in chemobabel: the file ``#1'' does not exist.
\end{minipage}}%
@@ -247,7 +262,7 @@
\let\chemob@bel@nocrop\relax
\DeclareOption{nocrop}{\let\chemob@bel@nocrop\@empty}
% default settings
-\ExecuteOptions{pdf,inkscape}
+\ExecuteOptions{\chemob@belimgExt@default,inkscape}
% handle user settings - arbitrary order allowed
\ProcessOptions*\relax
\ifx\chemob@bel@nocrop\relax \else
@@ -279,7 +294,7 @@
}
\def\chemob@bel@atenddocument{%
\ifnum\chemob@bel@status>\z@ % at least one is not an image
- \PackageWarningNoLine{chemobabel}{%
+ \chemob@bel@warn{%
Some processing failed.\MessageBreak
Please rerun}%
\else % all images
@@ -303,13 +318,13 @@
% 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}{%
+ \chemob@bel@warn{%
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}{%
+ \chemob@bel@warn{%
Number of \noexpand\chemobabel changed.\MessageBreak
Please rerun}%
\fi
@@ -331,13 +346,13 @@
%% ----- Safety check before opening output file -----
\ifx\chemob@bel@jobname\chemob@bel@outname
- \PackageWarningNoLine{chemobabel}{%
+ \chemob@bel@warn{%
Wow! Your file name is `\chemob@bel@outname'!\MessageBreak
Option [extract] ignored to avoid overwriting}
\expandafter\endinput
\fi
-\PackageWarningNoLine{chemobabel}{%
+\chemob@bel@warn{%
You are using [extract] option.\MessageBreak
No chemical structures will be printed}
@@ -368,7 +383,7 @@
\immediate\write\chemob@bel@outfile{\string\end{document}}%
\immediate\closeout\chemob@bel@outfile
\chemob@bel@ifnochem{}{%
- \PackageWarningNoLine{chemobabel}{%
+ \chemob@bel@warn{%
Some chemical structures are extracted.\MessageBreak
Run 'pdflatex -shell-escape ChemFigFile.tex'}}%
}