Debian Codegraph @

texmf-dist/source/latex/chemobabel/chemobabel.dtx

raw
1 %#!make chemobabel.pdf
2 %%
3 %% This document describes the usage of `chemobabel.sty',
4 %% a LaTeX package for generating chemical structural formulas
5 %% using Open Babel and Inkscape.
6 %%
7 %% Copyright 2014-2022 Acetaminophen (Hironobu YAMASHITA)
8 %% Email : h.y.acetaminophen[a t]gmail.com
9 %% GitHub : https://github.com/aminophen
10 %% Blog : http://acetaminophen.hatenablog.com/
11 %% Twitter : @aminophen
12 %%
13 %
14 \documentclass[12pt]{ltjsarticle}
15 \usepackage[margin=20mm]{geometry}
16 \usepackage[english]{babel}
17 \usepackage[nofontspec,defaultsups]{newpxtext}
18 \usepackage[zerostyle=c,straightquotes]{newtxtt}
19 \usepackage{newpxmath}
20 \usepackage{ascmac}
21 \usepackage[librsvg]{chemobabel}
22 \usepackage[bookmarksnumbered=true,hidelinks,%
23 pdftitle={User Manual for chemobabel.sty},%
24 pdfauthor={Hironobu Yamashita (Acetaminophen)},%
25 pdfsubject={TeX \& LaTeX Advent Calendar 2014},%
26 pdfkeywords={chemistry,open babel,chemdraw,smiles}]{hyperref}
27 \usepackage{footnotebackref}
28 % --- Change the style of captions
29 % --- (Japanese jsarticle style => English style)
30 \makeatletter
31 \long\def\@makecaption#1#2{%
32 \vskip\abovecaptionskip
33 \sbox\@tempboxa{#1: #2}%
34 \global\@minipagefalse
35 \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
36 \vskip\belowcaptionskip}
37 \makeatother
38 % --- XyMTeX logo definition
39 \newcount\TestCount
40 \def\XyM{\ifnum\fam=-1\relax\fam=0\relax\fi\TestCount=\fam
41 X\kern-.30em\smash{\raise.50ex\hbox{$\fam\TestCount\Upsilon$}}%
42 \kern-.30em{M}}
43 \def\XyMTeX{\XyM\kern-.1em\TeX}
44 % --- misc
45 \def\Lpack#1{\textsf{#1}}
46 \def\Lcode#1{\texttt{#1}}
47 \def\Lmeta#1{\textit{#1}}
48 \def\Lver#1{\Lpack{chemobabel} #1}
49 \def\TikZ{Ti\textit{k}Z}
50 % ------
51 \title{\Lpack{chemobabel} \\[1ex]
52 \normalsize --- Chemical Structures from MDL Molfiles,
53 ChemDraw Files or SMILES Notations --- \\
54 %<ja> 化学構造式をMOLファイルやChemDrawファイル,SMILES表記法から自動生成
55 }
56 \author{Hironobu Yamashita (@aminophen)}
57 \begin{document}
58 \renewcommand{\figurename}{Fig.\,}
59 \pagenumbering{roman}
60 \maketitle
61
62 %<*en>
63 This document (\jobname.pdf) describes the usage of \Lpack{chemobabel.sty},
64 a \LaTeX\ package for \textbf{generating chemical structural formulas}
65 to be inserted in your documents.
66 The formulas can be generated \textbf{from many kinds of chemical data
67 formats}, including MDL Molfiles, ChemDraw files and even from
68 SMILES notations, with the help of Open Babel.
69 The formulas below are generated using this method.\footnote{Unless
70 otherwise noted, this documentation used \Lcode{\input{obversion.txt}}}
71
72 日本語版ドキュメントはchemobabel-ja.pdfを参照してください。
73 %</en>
74 %<*ja>
75 この文書では,\textbf{化学構造式を生成}して\LaTeX の文書中に挿入するための
76 パッケージである\Lpack{chemobabel.sty}の使い方を説明します。
77 構造式はOpen Babelの機能を利用することにより,MDL Molfile, ChemDrawファイル,
78 さらにはSMILES表記法を含む\textbf{さまざまな化学データ形式から生成}できます。
79 以下の構造式はこの方法によって出力されたものです\footnote{特に断りがない
80 限り,この文書で使用した版は\Lcode{\input{obversion.txt}}です。}。
81
82 For English documentation, please refer to chemobabel-en.pdf.
83 %</ja>
84
85 \begin{figure}[ht]
86 \centering
87 \chemobabel[width=65mm]{draw/Firefly luciferin.mol}{} \quad
88 \chemobabel*[width=90mm]{draw/Brevetoxin A.mol}
89 \caption{Firefly luciferin \& Brevetoxin A (from MDL Molfiles)}
90 \end{figure}
91
92 \begin{figure}[ht]
93 \centering
94 \chemobabel[width=80mm]{draw/ATP.cdx}{} \hspace{1cm}
95 \chemobabel*[width=30mm]{draw/Glucose.cdx}
96 \caption{ATP (Adenosine triphosphate) \& Glucose (from ChemDraw files)}
97 \end{figure}
98 \begin{center}\small
99 Note: with Open Babel 3.1.1 the chemical structure of ATP from the .cdx file
100 becomes wrong.\\ See \url{https://github.com/openbabel/openbabel/issues/338}
101 \end{center}
102
103 \begin{figure}[ht]
104 \centering
105 \smilesobabel[width=36mm]{CCO}{} \hspace{1cm}
106 \smilesobabel*[width=40mm]{CC(C(=O)O)N} \hspace{1cm}
107 \smilesobabel*[width=30mm]{C1[C@H](C)C[C@@H](O)C1}
108 \caption{Ethanol, Alanine \& (1\textit{S},3\textit{S})-3-Methylcyclopentanol (from SMILES notations)}
109 \end{figure}
110
111 \begin{figure}[ht]
112 \centering
113 \smilesobabel*[width=30mm]{CC(=O)Nc1ccc(cc1)O} \hspace{1cm}
114 \smilesobabel*[width=40mm]{C([C@@H]1[C@H]([C@@H]([C@H]([C@H](O1)O)O)O)O)O}
115 \caption{Acetaminophen (Paracetamol) \& $\alpha$-\textsc{d}-Glucose (from SMILES notations)}
116 \end{figure}
117
118 \begin{figure}[ht]
119 \centering
120 %<en>This package is maintained on GitHub:\par
121 %<ja>このパッケージはGitHubで管理しています。\par
122 \url{https://github.com/aminophen/chemobabel}\par
123 %<en>If you have questions, please let me know.
124 %<ja>問い合わせや改善案などはGitHubのIssuesへお願いします。
125 \end{figure}
126
127 \begin{figure}[ht]
128 \centering
129 %<en>Also available on CTAN:
130 %<ja>CTANからも入手可能です →
131 \url{https://www.ctan.org/pkg/chemobabel}\par
132 %<en>Distributed with \TeX\ Live and MiK\TeX.
133 %<en>Below is a short description for CTAN:\par
134 %<ja>\TeX\ LiveやMiK\TeX でも配布されています。
135 %<ja>以下はCTANの短い紹介文です。\par
136 \begin{screen}
137 This package provides a way to convert and include
138 chemical structure graphics from various chemical formats,
139 such as ChemDraw files, MDL molfile or SMILES notations
140 using Open Babel.
141 To use this \LaTeX\ package, it is necessary to enable execution
142 of the following external commands via \Lcode{latex -shell-escape}.
143 \begin{itemize}
144 \item \Lcode{obabel} (Open Babel)
145 \item \Lcode{inkscape} or \Lcode{rsvg-convert}
146 (for SVG -> PDF/EPS conversion)
147 \item \Lcode{pdfcrop} or \Lcode{ps2eps}
148 (optional; for cropping large margins of PDF/EPS)
149 \end{itemize}
150 \end{screen}
151 \end{figure}
152
153 \clearpage
154 \setcounter{tocdepth}{3}
155 \tableofcontents
156
157 \clearpage
158 \pagenumbering{arabic}
159
160 %<*en>
161 \section{Introduction}
162 %</en>
163 %<*ja>
164 \section{はじめに}
165 %</ja>
166
167 %<*en>
168 \subsection{Motivation for Development}
169 %</en>
170 %<*ja>
171 \subsection{開発の動機}
172 %</ja>
173
174 %<*en>
175 As you already know, \LaTeX\ is being used all over the world.
176 However, when it comes to drawing chemical strucutral formulas,
177 ways of inserting formulas into \LaTeX\ documents are very limited.
178 I think it is mainly due to lack of both reliable and simple methods
179 of doing this that many of the researchers in chemistry are reluctant
180 to use \LaTeX\ system.
181 %</en>
182 %<*ja>
183 ご存じのとおり,\LaTeX は世界中で使われています。
184 しかし,化学構造式を描くという点で考えると,
185 \LaTeX 文書中に構造式を挿入する手段は非常に限られています。
186 この目的を達成する確実かつ容易な方法が存在しないことは,化学分野における
187 多くの研究者が\LaTeX システムを使わない要因になっていると考えられます。
188 %</ja>
189
190 %<*en>
191 Some \TeX/\LaTeX\ macros and packages are already available from
192 \href{http://www.ctan.org/}{CTAN}:
193 \begin{itemize}
194 \item \href{http://www.ctan.org/pkg/xymtex}{\XyMTeX}:
195 a set of packages for drawing chemical structural formulas
196 \item \href{http://www.ctan.org/pkg/chemfig}{\Lpack{chemfig}}:
197 a package which draws molecules using \TikZ
198 \end{itemize}
199 These packages are reliable and almost all kinds of structural formulas
200 can be drawn in a consistent way. However, a lot of practice will be
201 required before one can come to make full use of them.
202 %</en>
203 %<*ja>
204 すでに\href{http://www.ctan.org/}{CTAN}からいくつかのパッケージが利用可能です:
205 \begin{itemize}
206 \item \href{http://www.ctan.org/pkg/xymtex}{\XyMTeX}:
207 化学構造式を描くためのパッケージ集
208 \item \href{http://www.ctan.org/pkg/chemfig}{\Lpack{chemfig}}:
209 \TikZ を利用して構造式を描画するパッケージ
210 \end{itemize}
211 これらのパッケージは確実で,あらゆる構造式を一貫性をもって描画することができます。
212 しかし,十分にその機能を活用できるようになるには相当の熟練を要します。
213 %</ja>
214
215 %<*en>
216 You can also insert structural formulas with \verb|\includegraphics| of
217 PDF or EPS files exported from special softwares for chemists, such as
218 \href{http://www.cambridgesoft.com/Ensemble_for_Chemistry/ChemDraw/}{ChemDraw}
219 and other similar programs.
220 In this case, you have to save files in both chemical formats
221 (such as \verb|.cdx| or \verb|.mol|) and graphical formats
222 (\verb|.pdf| or \verb|.eps|) manually.
223 %</en>
224 %<*ja>
225 化学者向けの専用ツール
226 (\href{http://www.cambridgesoft.com/Ensemble_for_Chemistry/ChemDraw/}{ChemDraw}など)
227 でPDFやEPS形式で出力し,\verb|\includegraphics|によって
228 構造式を取り込むという手段もあります。
229 この場合,化学用のフォーマット(\verb|.cdx| や \verb|.mol| など)と
230 画像フォーマット(\verb|.pdf| や \verb|.eps| など)の両方で保存する必要があります。
231 %</ja>
232
233 %<*en>
234 This new package, \Lpack{chemobabel.sty}, will offer a new choice for
235 chemists who need chemical structures inserted in their \LaTeX\ documents.
236 In this method, we use \href{http://openbabel.org/}{Open Babel} for
237 generating chemical structural formulas in SVG format,
238 and \href{https://inkscape.org/en/}{Inkscape} for converting SVG to PDF/EPS.
239 Both programs are open source and cross-platform, and being actively maintained.
240 %</en>
241 %<*ja>
242 新しいパッケージ \Lpack{chemobabel.sty} は,\LaTeX 文書中に化学構造式を
243 挿入する必要がある化学者に新たな選択肢を提供することでしょう。
244 この方法では,\href{http://openbabel.org/}{Open Babel}によって
245 SVG形式の構造式画像を生成し,
246 さらに\href{https://inkscape.org/ja/}{Inkscape}によってSVGから
247 PDFまたはEPS形式の画像に変換します。
248 どちらのプログラムもオープンソースかつクロスプラットフォームであり,
249 盛んに開発が行われています。
250 %</ja>
251
252 %<*en>
253 \paragraph{About Open Babel}
254
255 Open Babel is a toolbox specially designed to handle many kinds of
256 chemical data. It is an open, collaborative project allowing anyone to search,
257 convert, analyze, or store data from molecular modeling, chemistry,
258 solid-state materials, biochemistry, or related areas.
259 See \href{http://openbabel.org/}{Official Website} for detail.
260 %</en>
261 %<*ja>
262 \paragraph{Open Babelについて}
263
264 Open Babelはさまざまな化学データを扱うために特別に設計されたツールです。
265 オープンな共同プロジェクトで,分子モデリング・化学・固体物性・生化学や
266 関連分野のデータを誰もが検索・変換・分析・保存できることを目指しています。
267 詳細は\href{http://openbabel.org/}{公式サイト}を参照してください。
268 %</ja>
269
270 \clearpage
271
272 %<*en>
273 \subsection{Idea and Approach}
274 %</en>
275 %<*ja>
276 \subsection{着想とアプローチ}
277 %</ja>
278
279 %<*en>
280 First I found a post on Noel O'Blog \cite{NOB1}, \cite{NOB2} and
281 the comment \cite{JLA} about generating chemical structural formulas
282 from SMILES notations using Open Babel.
283 I thought the method described in these posts were very interesting,
284 but I didn't like all the programs could be executed by
285 \verb|-shell-escape| option.
286 At the same time, I encountered a macro for copying all
287 \verb|\includegraphics| from one source file to another \cite{OKU},
288 which made me conceive of an idea of extracting minimal source code
289 which needs \verb|-shell-escape| option.
290
291 I thought this method would be applicable to converting ChemDraw files into
292 graphics, but I could not find any project attempting to realize this idea.
293 I found a project named
294 \href{http://chemdrawinlatex.sourceforge.net/}{Chemdraw in \LaTeX}
295 on Sourceforge, but now it was closed.
296 This drove me to develop a new package to simplify the process for
297 inserting chemical structural formulas into \LaTeX\ documents.
298 %</en>
299
300 %<*ja>
301 最初にOpen Babelを用いてSMILES表記から化学構造式を生成するという
302 Noel O'Blog の記事\cite{NOB1}, \cite{NOB2}とコメント\cite{JLA}を見つけました。
303 これらの投稿に示された手法は非常におもしろいと思いましたが,
304 すべてのプログラムが \verb|-shell-escape| オプションによって実行されて
305 しまうことがあまり好きではありませんでした。
306 それと同じころ,あるソース中の \verb|\includegraphics| を
307 別のソースに書き出すというマクロ\cite{OKU}を偶然みつけ,
308 このとき私は \verb|-shell-escape| が必要な最小のコードだけを抽出する
309 という着想を得ました。
310
311 この方法はChemDrawファイルを画像に変換する目的にも応用できると考えたのですが,
312 この発想を実現したプロジェクトが見当たらず,ただ一つ見つけたSourceforgeの
313 \href{http://chemdrawinlatex.sourceforge.net/}{Chemdraw in \LaTeX}は
314 すでに終了していました。そこで,化学構造式を\LaTeX 文書中に挿入する手順を
315 簡略化するパッケージを開発しようと考えました。
316 %</ja>
317
318 \clearpage
319
320 %<*en>
321 \section{Before you begin}
322 %</en>
323 %<*ja>
324 \section{パッケージを使う前に}
325 %</ja>
326
327 %<*en>
328 \subsection{Installing dependent softwares}
329 %</en>
330 %<*ja>
331 \subsection{依存ソフトウェアのインストール}
332 %</ja>
333
334 %<*en>
335 First, you have to install \href{http://openbabel.org/}{Open Babel} and
336 \href{https://inkscape.org/en/}{Inkscape}
337 (or \href{http://librsvg.sourceforge.net/download/}{librsvg}) on your
338 computer, and export PATH to the required command-line programs,
339 \Lcode{obabel} and \Lcode{inkscape} (or \Lcode{rsvg-convert}).
340 The package also uses \Lcode{pdfcrop} (or \Lcode{ps2eps}) to
341 crop large margins, but it is included in \TeX\ Live.
342 You can confirm by executing following commands:
343 %</en>
344 %<*ja>
345 初めにコンピュータに\href{http://openbabel.org/}{Open Babel}と
346 \href{https://inkscape.org/ja/}{Inkscape}(または
347 \href{http://librsvg.sourceforge.net/download/}{librsvg})をインストールし,
348 必要なコマンドラインプログラムである
349 \Lcode{obabel}と\Lcode{inkscape}(または\Lcode{rsvg-convert})に
350 PATHを通します。
351 なお,生成画像の大きな余白を切り取るために\Lcode{pdfcrop}(または
352 \Lcode{ps2eps})も利用しますが,これは\TeX\ Liveに収録されています。
353 正しくPATHが通っているかどうかは以下のコマンドによって確認できます:
354 %</ja>
355 %<en>In UNIX operating system:
356 %<ja>UNIX系の場合:
357 \begin{verbatim}
358 $ which obabel
359 $ which inkscape (if you choose inkscape)
360 $ which rsvg-convert (if you choose librsvg)
361 \end{verbatim}
362
363 %<en>In Windows operating system:
364 %<ja>Windowsの場合:
365 \begin{verbatim}
366 > where obabel
367 > where inkscape (if you choose inkscape)
368 > where rsvg-convert (if you choose librsvg)
369 \end{verbatim}
370
371 %<*en>
372 And when you get some command echo, installation should be successful.
373 %</en>
374 %<*ja>
375 何らかのディレクトリ名が返ってきた場合は,正しくインストールできているはずです。
376 %</ja>
377
378 %<*en>
379 \subsection{Loading the package}
380 %</en>
381 %<*ja>
382 \subsection{パッケージの読み込み}
383 %</ja>
384
385 %<*en>
386 In the preamble of your document, declare
387 \begin{verbatim}
388 \usepackage{chemobabel}
389 \end{verbatim}
390 to load \Lpack{chemobabel} package.
391 The package depends on \Lpack{graphicx}.
392 %</en>
393 %<*ja>
394 プリアンブルに
395 \begin{verbatim}
396 \usepackage{chemobabel}
397 \end{verbatim}
398 と宣言して\Lpack{chemobabel}パッケージを読み込みます。
399 これは\Lpack{graphicx}パッケージに依存しますので,
400 もし(u)p\LaTeX を使っていてDVIドライバに\Lcode{dvipdfmx}を使用する場合は
401 ドライバオプション \verb+[dvipdfmx]+ をクラスオプション(グローバル)に
402 付けるのを忘れないようにしてください。
403 %</ja>
404
405 \clearpage
406
407 %<*en>
408 \section{Basic Usage}
409 %</en>
410 %<*ja>
411 \section{基本的な使い方}
412 %</ja>
413 \label{basic}
414
415 %<*en>
416 \subsection{Conversion from Chemical Structure Data Files}
417 %</en>
418 %<*ja>
419 \subsection{化学構造式ファイルからの変換}
420 %</ja>
421
422 %<*en>
423 Suppose you have \verb|ATP.cdx|, a file with chemical structural formula
424 of ATP (Adenosine triphosphate) drawn in ChemDraw, and
425 \verb|Brevetoxin A.mol|, a MDL Molfile which can be obtained from
426 \href{http://www.chemspider.com/}{ChemSpider} (originally \verb|9041092.mol|).
427
428 Use \verb|\chemobabel| command as follows. I put original files in a
429 subdirectory \Lcode{draw}, so added \Lcode{draw/} before the actual filename.
430 Of course you can put in the same directory with your \LaTeX\ file.
431 %</en>
432 %<*ja>
433 \verb|ATP.cdx| はATP(アデノシン三リン酸)の構造式を
434 ChemDrawで描画したファイル,\verb|Brevetoxin A.mol| は
435 \href{http://www.chemspider.com/}{ChemSpider}から入手できるファイルです
436 (もとのファイル名は \verb|9041092.mol| となっています)。
437
438 \verb|\chemobabel| コマンドは本文中で以下のようにして使います。
439 ここでは元のファイルを\Lcode{draw}というサブディレクトリに置いたので,
440 ファイル名の前に \Lcode{draw/} を付けました。
441 もちろん \LaTeX ソースと同一ディレクトリに置くこともできます。
442 %</ja>
443
444 \begin{verbatim}
445 \chemobabel[width=90mm]{draw/ATP.cdx}{}
446 \chemobabel*[width=120mm]{draw/Brevetoxin A.mol}
447 \end{verbatim}
448
449 %<*en>
450 Then, typeset with \verb|-shell-escape| option.
451 Remember to use this option, otherwise it won't allow \LaTeX\ to
452 call any external command-line programs, such as obabel and inkscape!
453 \begin{verbatim}
454 $ pdflatex -shell-escape test.tex
455 \end{verbatim}
456 You will see in \verb|chemobabelimgdir| subdirectory ``chemobabelimg[NUM].pdf'',
457 and output file test.pdf will be Figure~\ref{fig:chem1}:
458 %</en>
459 %<*ja>
460 \LaTeX ファイル名がtest.texだとすると,以下のように
461 \verb|-shell-escape| オプションを与えてタイプセットします。
462 このオプションを与えることで,\LaTeX が外部プログラムである
463 obabelやinkscapeを呼んで実行できるようになります。
464 \begin{verbatim}
465 $ platex -shell-escape test.tex
466 \end{verbatim}
467 するとサブディレクトリ \verb|chemobabelimgdir| 以下に
468 「chemobabelimg[NUM].pdf」というファイルが生成します。
469 得られたtest.dviに対して
470 \begin{verbatim}
471 $ dvipdfmx test.dvi
472 \end{verbatim}
473 と実行すると,出力される「test.pdf」は図\ref{fig:chem1}のようになります。
474 %</ja>
475
476 \begin{figure}[h]
477 \centering
478 \chemobabel[width=90mm]{draw/ATP.cdx}{} \\ \vspace{1cm}
479 \chemobabel*[width=120mm]{draw/Brevetoxin A.mol}
480 \caption{Conversion from ATP.cdx and Brevetoxin A.mol}\label{fig:chem1}
481 \end{figure}
482
483 %<en>The syntax is:
484 %<ja>構文は以下のとおりです。
485 \begin{center}
486 \verb|\chemobabel[|\Lmeta{options}\verb|]{|\Lmeta{filename}\verb|}{|\Lmeta{obabel options}\verb|}| \\
487 \verb|\chemobabel*[|\Lmeta{options}\verb|]{|\Lmeta{filename}\verb|}|
488 \end{center}
489 %<*en>
490 \verb|\chemobabel| takes one optional parameter and two mandatory parameters.
491 \begin{itemize}
492 \item The optional parameter \Lmeta{options} in the box brackets
493 is passed to \verb|\includegraphics|.
494 If omitted, the default ``clip,scale=1' is assumed.
495 \item The first mandatory parameter \Lmeta{filename} is the file name
496 which contains chemical structural formula.
497 \item The second mandatory parameter \Lmeta{obabel options}
498 is passed to \verb|obabel| command
499 (see Section \ref{depict} for some examples).
500 \end{itemize}
501 If you want to leave the second parameter empty,
502 a shorthand form \verb|\chemobabel*| is also available
503 (since \Lver{v0.9k [2022/10/09]}).
504 %</en>
505 %<*ja>
506 \verb|\chemobabel| は1つのオプション引数と2つの必須引数をとります。
507 \begin{itemize}
508 \item 角括弧内のオプション引数は \verb|\includegraphics| に渡されます。
509 省略された場合は \verb|clip,scale=1| とみなされます。
510 \item 必須引数の1つめには化学構造式が描かれたファイル名を与えます。
511 \item 必須引数の2つめには \verb|obabel| に送るオプション
512 (例は第\ref{depict}節を参照)を指定します。
513 \end{itemize}
514 必須引数の2つめを空にしたい場合は,
515 短縮形として \verb|\chemobabel*| を使用することもできます
516 (\Lver{v0.9k [2022/10/09]}以降)。
517 %</ja>
518
519 %<*en>
520 \subsection{Conversion from SMILES Notations}
521 %</en>
522 %<*ja>
523 \subsection{SMILES表記法からの変換}
524 %</ja>
525
526 %<*en>
527 You can also write SMILES notations directly in your \LaTeX\ file to be
528 converted into structural formulas.
529 For example, \verb|CCO| is the SMILES notation of ethanol, and
530 \verb|CC(=O)Nc1ccc(cc1)O| is that of acetaminophen (paracetamol).
531 Use \verb|\smilesobabel| command as follows:
532 %</en>
533 %<*ja>
534 \LaTeX ソースファイル中に直接SMILES表記を書き込んで,
535 構造式に変換することもできます。
536 例えば,\verb|CCO| はエタノールのSMILES表記,
537 \verb|CC(=O)Nc1ccc(cc1)O| はアセトアミノフェンのSMILES表記です。
538 \verb|\smilesobabel| コマンドを以下のようにして使います:
539 %</ja>
540
541 \begin{verbatim}
542 \smilesobabel{CCO}{}
543 \smilesobabel*[width=25mm]{CC(=O)Nc1ccc(cc1)O}
544 \end{verbatim}
545
546 %<*en>
547 Again typeset with \verb|-shell-escape| option:
548 \begin{verbatim}
549 $ pdflatex -shell-escape test.tex
550 \end{verbatim}
551 This time you will get ``smilesobabelimg[NUM].pdf'' and ``test.pdf''
552 as Figure~\ref{fig:smi1}.
553 %</en>
554 %<*ja>
555 やはり \verb|-shell-escape| オプションを付けてタイプセットします。
556 \begin{verbatim}
557 $ platex -shell-escape test.tex
558 $ dvipdfmx test.dvi
559 \end{verbatim}
560 すると今度は「smilesobabelimg[NUM].pdf」のようなファイルが生成し,
561 出力される「test.pdf」は図\ref{fig:smi1}のようになります。
562 %</ja>
563 \begin{figure}[h]
564 \centering
565 \smilesobabel{CCO}{} \quad
566 \smilesobabel*[width=25mm]{CC(=O)Nc1ccc(cc1)O}
567 \caption{Conversion from SMILES notation}\label{fig:smi1}
568 \end{figure}
569
570 %<en>The syntax is:
571 %<ja>構文は以下のとおりです。
572 \begin{center}
573 \verb|\smilesobabel[|\Lmeta{options}\verb|]{|\Lmeta{SMILES notation}\verb|}{|\Lmeta{obabel options}\verb|}| \\
574 \verb|\smilesobabel*[|\Lmeta{options}\verb|]{|\Lmeta{SMILES notation}\verb|}|
575 \end{center}
576 %<*en>
577 The only difference from \verb|\chemobabel| is that
578 \Lmeta{SMILES notation} should be placed in the first braces.
579 You can put any kinds of SMILES notations in parameters of
580 \verb|\smilesobabel|, even when they contain some special characters
581 such as a backslash (\verb|\|) and a percent symbol (\verb|%|).
582 Similarly, parameters of \verb|\chemobabel| can also contain
583 these special characters.
584 %</en>
585 %<*ja>
586 \verb|\chemobabel| との唯一の違いは,中括弧の1つめにSMILES表記法の
587 テキストを与えることだけです。
588 \verb|\smilesobabel| の引数としては,任意のSMILES表記を用いることができます
589 (バックスラッシュ (\verb|\|) やパーセント記号 (\verb|%|) のような
590 特別な文字が入っていてもかまいません)。
591 なお,\verb|\chemobabel| の引数についても同様に,
592 特別な文字を含むことができる設計になっています。
593 %</ja>
594 \begin{verbatim}
595 \smilesobabel*[width=28mm]{Cl/C=C/Br}
596 \smilesobabel*[width=28mm]{Cl/C=C\Br}
597 \end{verbatim}
598 \begin{figure}[h]
599 \centering
600 \smilesobabel*[width=28mm]{Cl/C=C/Br} \quad
601 \smilesobabel*[width=28mm]{Cl/C=C\Br}
602 \end{figure}
603
604 %<*en>
605 \noindent \textbf{Notes for users of earlier versions \Lver{v0.6 [2015/06/29]} or older}
606
607 In earlier versions of \Lpack{chemobabel}, it was necessary for users
608 to pay another attention when using these \LaTeX\ special characters.
609 However, the workaround I had suggested before was far from desirable
610 because ``casual \LaTeX\ users'' were forced to change category codes
611 of these characters manually.
612
613 To solve this problem, I improved the internal macros since \Lver{v0.7 [2015/08/26]}.
614 Now you can put any kinds of SMILES notations directly without worrying
615 about special characters (\verb|\|, \verb|%|, etc).
616 Note that the undesirable workaround (like changing \verb|\catcode| inside
617 \verb|\begingroup| ... \verb|\endgroup|) has now become rather harmful.
618 %</en>
619
620 %<*ja>
621 \noindent \textbf{\Lver{v0.6 [2015/06/29]}以前の旧バージョンのユーザに対する注意}
622
623 古いバージョンの\Lpack{chemobabel}では,
624 これらの\LaTeX で特別な意味を持つ文字に注意を払う必要がありました。
625 従来私が紹介してきた回避策は“カジュアルな \LaTeX ユーザ”に
626 カテゴリーコードを手動で変更させていたため,好ましいものではありませんでした。
627
628 この問題を解決するため,\Lver{v0.7 [2015/08/26]}以降では
629 パッケージ本体の側でこれらの文字をサポートするように改良を施しました。
630 これにより,\verb|\| や \verb|%| といった特別な文字を心配することなく,
631 任意のSMILES表記を直接引数に渡すことができるようになっています。
632 従来の回避策(\verb|\begingroup| ... \verb|\endgroup| 内で \verb|\catcode| を
633 変更する方法)は今ではむしろ有害になっていますので,注意してください。
634 %</ja>
635
636 \clearpage
637
638 %<*en>
639 \subsection{Package options}
640 %</en>
641 %<*ja>
642 \subsection{パッケージオプション}
643 %</ja>
644
645 %<*en>
646 By default, \Lpack{chemobabel} converts chemical structures into
647 PDF images using Inkscape. However, you can switch the image format
648 and the conversion program if you like.
649
650 When you are using drivers which do not support PDF figures (such as dvips),
651 it will be helpful if \Lpack{chemobabel} converts them into EPS images.
652 For this purpose, you can use:
653 %</en>
654 %<*ja>
655 \Lpack{chemobabel} パッケージは,デフォルトでは化学構造式をInkscapeによって
656 PDF形式の画像ファイルに変換して文書中に取り込みます。
657 しかし,オプションで画像形式と変換プログラムを変更することができます。
658
659 dvipsなどのPDF非対応のドライバを使用する場合は,EPS形式の画像ファイルに
660 変換したほうが便利でしょう。この場合
661 %</ja>
662 \begin{verbatim}
663 \usepackage[eps]{chemobabel}
664 \end{verbatim}
665 %<*en>
666 The option \verb|eps| switches the image format
667 (that is, output format from Inkscape) into EPS (since
668 \Lver{v0.9d [2016/02/28]}).\footnote{Moreover, since
669 \Lver{v0.9l [2022/10/22]}, the package automatically switches to
670 EPS mode when using dvips.}
671
672 You can also change the image conversion program from ``Inkscape'' to
673 ``rsvg-convert'' (since \Lver{v0.9e [2016/03/07]}).
674 The program rsvg-convert is faster than inkscape, so it will be useful.
675 For this purpose, use \verb|librsvg| option:
676 %</en>
677 %<*ja>
678 というように \verb|eps| オプションを指定すれば,内部でInkscapeから出力される
679 画像形式をPDFではなくEPSに変更します(\Lver{v0.9d [2016/02/28]}以降)
680 \footnote{\Lver{v0.9l [2022/10/22]}以降ではさらに,dvipsの場合に
681 自動的にEPSに切り替えるようにしました。}。
682
683 また,画像変換プログラムを Inkscape から rsvg-convert に変更することもできます
684 (\Lver{v0.9e [2016/03/07]}以降)。
685 rsvg-convertはInkscapeより高速ですから,便利かもしれません。
686 この場合は,以下のように \verb|librsvg| オプションを指定します。
687 %</ja>
688 \begin{verbatim}
689 \usepackage[librsvg]{chemobabel}
690 \end{verbatim}
691 %<*en>
692 The default behavior is equivalent to the \verb|pdf| and \verb|inkscape| options:
693 %</en>
694 %<*ja>
695 デフォルトは \verb|pdf| オプションと \verb|inkscape| オプションを
696 指定した場合と等価です。
697 %</ja>
698 \begin{verbatim}
699 \usepackage[pdf,inkscape]{chemobabel}
700 \end{verbatim}
701
702 %<*en>
703 Moreover, Open Babel v2.4.0 or later versions generate images with
704 a rather large margin. To avoid this, the images are cropped
705 using \verb|pdfcrop| for PDF or \verb|ps2eps| for EPS
706 (since \Lver{v0.9i [2022/09/12]}).
707 If you want to disable this cropping, please add \verb|nocrop| option:
708 %</en>
709 %<*ja>
710 さらに,Open Babel v2.4.0以降で生成される画像はデフォルトで余白が大きいため,
711 \verb|pdfcrop|(PDFの場合)あるいは\verb|ps2eps|(EPSの場合)で
712 クロップしています(\Lver{v0.9i [2022/09/12]}以降)。
713 これをやめたい場合は \verb|nocrop| オプションを指定してください。
714 %</ja>
715 \begin{verbatim}
716 \usepackage[nocrop]{chemobabel}
717 \end{verbatim}
718
719 \clearpage
720
721 %<*en>
722 \subsection{For Safer Typesetting...}
723 %</en>
724 %<*ja>
725 \subsection{安全なタイプセットのために}
726 %</ja>
727 \label{extract}
728
729 %<*en>
730 With the basic method described in Section \ref{basic},
731 you will get desired output in almost any situation.
732 However, it is sometimes NOT desirable to use \verb|-shell-escape| option,
733 because with that option \LaTeX\ can call \emph{any} external command-line
734 programs whether you like it or not.
735 This means that there is a chance for unknown programs to be executed,
736 and this can be dangerous especially in case that you don't write your
737 own \LaTeX\ code. To avoid this problem, I provide a workaround for
738 extracting all \verb|\chemobabel| and \verb|\smilesobabel| commands
739 to another \LaTeX\ file (Reference: \TeX\ Forum \cite{OKU}).
740
741 All you have to do is to add \verb|extract| option when loading the package:
742 %</en>
743 %<*ja>
744 第\ref{basic}節で述べた基本的な使い方で,ほとんどの場合問題ないでしょう。
745 しかし,\verb|-shell-escape| オプションを付けてタイプセットするため,
746 好むと好まざるとにかかわらず\LaTeX が\emph{どんな外部コマンドでも}実行
747 できてしまいます。つまり,知らないうちにプログラムが実行されてしまう可能性を示唆
748 しており,これはとりわけ自分で書いた\LaTeX ソースでない場合には危険を伴います。
749 この問題を回避するために,\verb|\chemobabel| と \verb|\smilesobabel| コマンド
750 だけを別の \LaTeX ファイルに抽出するマクロを用意しています
751 (参考:\TeX\ Forum \cite{OKU})。
752
753 この場合は,パッケージを読み込む際に \verb|extract| オプションを付与してください。
754 %</ja>
755 \begin{verbatim}
756 \usepackage[extract]{chemobabel}
757 \end{verbatim}
758 %<*en>
759 When typesetting, usual command
760 \begin{verbatim}
761 $ pdflatex test.tex
762 \end{verbatim}
763 can be used.
764 With \verb|extract| option, all \Lpack{chemobabel} does is extracting
765 all \verb|\chemobabel| and \verb|\smilesobabel| commands from the
766 original \LaTeX\ file.
767 You will get ``ChemFigFile.tex'' in the current directory, a minimal
768 \LaTeX\ source file which includes all \verb|\chemobabel| and
769 \verb|\smilesobabel| commands.
770 You can simply typeset it by
771 %</en>
772 %<*ja>
773 タイプセットの際には通常の
774 \begin{verbatim}
775 $ platex test.tex
776 \end{verbatim}
777 というコマンドを使います。
778 \verb|extract| オプションを付けると,\Lpack{chemobabel}パッケージは
779 単に元の\LaTeX ソースから \verb|\chemobabel| と \verb|\smilesobabel| コマンド
780 だけを抽出するはたらきをします。
781 その結果,作業ディレクトリに「ChemFigFile.tex」というファイルが生成します。
782 これは元のソースに書かれていた \verb|\chemobabel| と \verb|\smilesobabel| コマンド
783 をすべて含む最小の \LaTeX ソースで,これは直接pdflatexでタイプセットできます。
784 %</ja>
785 \begin{verbatim}
786 $ pdflatex -shell-escape ChemFigFile.tex
787 \end{verbatim}
788 %<*ja>
789 欧文と同じ仕様に統一したため,抽出される「ChemFigFile.tex」では
790 \Lpack{graphicx}パッケージに \verb+[dvipdfmx]+ オプション
791 を与えずに読み込んでいます。したがって,
792 このタイプセットだけは\Lcode{pdflatex}を用いてください。
793 %</ja>
794 %<*en>
795 and you will get PDF figures in the same way
796 as described in Section \ref{basic}.
797 After this, typeset your own document again
798 (this time you should remove \verb|extract| option):
799 \begin{verbatim}
800 $ pdflatex test.tex
801 \end{verbatim}
802 This time you will get desired output ``test.pdf''
803 which includes figures properly.
804 This method will also save you a lot of time for typesetting.
805 %</en>
806 %<*ja>
807 すると,第\ref{basic}節と同様にPDF形式の図のファイルが生成しますので,
808 あとは \verb|extract| オプションを除去して再度
809 \begin{verbatim}
810 $ platex test.tex
811 $ dvipdfmx test.dvi
812 \end{verbatim}
813 と実行すれば,適切に図を取り込んだ望みどおりの「test.pdf」が得られます。
814 この方法を用いれば,タイプセットに要する時間を大幅に短縮することも期待できます。
815 %</ja>
816
817 %<*en>
818 \paragraph{Note on the option \Lcode{-output-directory}}
819
820 When using the option \Lcode{-output-directory} of \TeX,
821 the extracted code ``ChemFigFile.tex'' goes there
822 but the subdirectory \verb|chemobabelimgdir| and
823 generated images stay in the current working directory.
824 To process the resulting files correctly, it would be
825 necessary to move files properly.
826 %</en>
827 %<*ja>
828 \paragraph{注意:\Lcode{-output-directory}オプション}
829
830 \TeX の\Lcode{-output-directory}オプションを使用すると,
831 抽出ファイル「ChemFigFile.tex」はその指定先に書き出されますが,
832 サブディレクトリ \verb|chemobabelimgdir| と生成画像は
833 現在のディレクトリとなります。
834 従って,抽出ファイルと元のファイルを正しく処理するためには
835 ファイルを適切に配置する必要があります。
836 %</ja>
837
838 \clearpage
839
840 %<*en>
841 \section{Advanced Usage}
842 %</en>
843 %<*ja>
844 \section{高度な使い方}
845 %</ja>
846
847 %<*en>
848 \subsection{Options for Depiction}
849 %</en>
850 %<*ja>
851 \subsection{描画オプション}
852 %</ja>
853 \label{depict}
854
855 %<*en>
856 As I have already mentioned, in both \verb|\chemobabel| and \verb|\smilesobabel|,
857 you can give some \Lmeta{obabel options} in the second braces.
858 Here I will introduce some examples.
859 %</en>
860 %<*ja>
861 既に述べたとおり,\verb|\chemobabel| と \verb|\smilesobabel| の両方について,
862 2つめの中括弧に \Lmeta{obabel options} を与えることができます。
863 ここで,いくつかの有用な例を挙げておきます。
864 %</ja>
865 \begin{itemize}
866 \item
867 \begin{verbatim}
868 \smilesobabel{CC(=O)Nc1ccc(cc1)O}{-xa}
869 \end{verbatim}
870 %<en>executes a command which gives a formula with all carbon atoms shown:
871 %<ja>構造式中の全ての炭素原子を省略せずに描画するコマンドを実行します:
872 \begin{verbatim}
873 $ obabel -:"CC(=O)Nc1ccc(cc1)O" -O smilesobabelimg[NUM].svg -xa
874 \end{verbatim}
875 \item
876 \begin{verbatim}
877 \smilesobabel{CC(=O)Nc1ccc(cc1)O}{-xu -xC}
878 \end{verbatim}
879 %<en>gives one without element-specific atom coloring or terminal carbon atoms:
880 %<ja>元素の着色を行わず,末端の炭素原子を明示しない構造式を出力します:
881 \begin{verbatim}
882 $ obabel -:"CC(=O)Nc1ccc(cc1)O" -O smilesobabelimg[NUM].svg -xu -xC
883 \end{verbatim}
884 \item
885 \begin{verbatim}
886 \chemobabel{ATP.cdx}{-xd}
887 \end{verbatim}
888 %<en>You can add \Lcode{-xd} option to remove filenames from ChemDraw figures with Open Babel 2.x.
889 %<ja>Open Babel 2.x系列でChemDrawの図からファイル名を取り除くには,\Lcode{-xd} オプションを付けます:
890 \begin{verbatim}
891 $ obabel -:"ATP.cdx" -O chemobabelimg[NUM].svg -xd
892 \end{verbatim}
893 \end{itemize}
894
895 \begin{figure}[ht]
896 \centering
897 \smilesobabel[width=21mm]{CC(=O)Nc1ccc(cc1)O}{} \hspace{1cm}
898 \smilesobabel[width=25mm]{CC(=O)Nc1ccc(cc1)O}{-xa} \hspace{1cm}
899 \smilesobabel[width=21mm]{CC(=O)Nc1ccc(cc1)O}{-xu}
900 \caption{Acetaminophen (Paracetamol): Nothing, \Lcode{-xa}, \Lcode{-xu}}
901 SMILES: \verb|CC(=O)Nc1ccc(cc1)O|
902 \end{figure}
903
904 \begin{figure}[ht]
905 \centering
906 \smilesobabel[width=25mm]{C1[C@H](C)C[C@@H](O)C1}{} \hspace{1cm}
907 \smilesobabel[width=25mm]{C1[C@H](C)C[C@@H](O)C1}{-xC} \hspace{1cm}
908 \smilesobabel[width=25mm]{C1[C@H](C)C[C@@H](O)C1}{-xt}
909 \caption{(1\textit{S},3\textit{S})-3-Methylcyclopentanol: Nothing, \Lcode{-xC}, \Lcode{-xt}}
910 SMILES: \verb|C1[C@H](C)C[C@@H](O)C1|
911 \end{figure}
912
913 \begin{figure}[ht]
914 \centering
915 \smilesobabel[width=42mm]{CCc1cccc(c1)C(=O)Cl}{} \hspace{1cm}
916 \smilesobabel[width=42mm]{CCc1cccc(c1)C(=O)Cl}{-xa -xu} \hspace{1cm}
917 \smilesobabel[width=42mm]{CCc1cccc(c1)C(=O)Cl}{-xu -xC}
918 \caption{3-Ethylbenzoyl chloride: Nothing, \Lcode{-xa -xu}, \Lcode{-xu -xC}}
919 SMILES: \verb|CCc1cccc(c1)C(=O)Cl|
920 \end{figure}
921
922 \begin{figure}[ht]
923 \centering
924 \smilesobabel[width=42mm]{CCc1cccc(c1)C(=O)Cl}{--highlight "cC=O blue"} \hspace{1cm}
925 \smilesobabel[width=42mm]{CCc1cccc(c1)C(=O)Cl}{-xA --genalias}
926 \caption{3-Ethylbenzoyl chloride: \Lcode{--highlight "cC=O blue"}, \Lcode{-xA --genalias}}
927 SMILES: \verb|CCc1cccc(c1)C(=O)Cl|
928 \end{figure}
929
930 \begin{figure}[ht]
931 \centering
932 \chemobabel[width=65mm]{draw/Firefly luciferin.mol}{} \hspace{1cm}
933 \chemobabel[width=65mm]{draw/Firefly luciferin.mol}{-xa}
934 \caption{Firefly luciferin (from MDL Molfiles): Nothing, \Lcode{-xa}}
935 \end{figure}
936
937 \begin{figure}[ht]
938 \centering
939 \chemobabel[width=70mm]{draw/ATP.cdx}{} \hspace{1cm}
940 \chemobabel[width=70mm]{draw/ATP.cdx}{-xd}
941 \caption{ATP (from ChemDraw files): Nothing, \Lcode{-xd}}
942 \end{figure}
943
944 \begin{figure}[ht]
945 %<*en>
946 For more details, see
947 \href{http://openbabel.org/docs/dev/Command-line_tools/babel.html}{obabel and babel}
948 and
949 \href{http://openbabel.org/docs/dev/FileFormats/SVG_2D_depiction.html}{SVG depiction (svg)}
950 in Open Babel documentation.
951 %</en>
952 %<*ja>
953 より詳細にはOpen Babel documentationの
954 \href{http://openbabel.org/docs/dev/Command-line_tools/babel.html}{obabel and babel}または
955 \href{http://openbabel.org/docs/dev/FileFormats/SVG_2D_depiction.html}{SVG depiction (svg)}を
956 参照してください。
957 %</ja>
958 \end{figure}
959
960 \clearpage
961
962 %<*en>
963 \subsection{More complex structural formulas}
964 %</en>
965 %<*ja>
966 \subsection{より複雑な構造式}
967 %</ja>
968
969 %<*en>
970 Open Babel can generate more complex structural formulas from SMILES notations.
971 %</en>
972 %<*ja>
973 Open BabelはSMILES表記から複雑な構造式を生成することができます。
974 %</ja>
975
976 \begin{figure}[ht]
977 \centering
978 \smilesobabel*[width=55mm]{CN1CC[C@]23c4c5ccc(c4O[C@H]2[C@H](C=C[C@H]3[C@H]1C5)O)O}
979 \caption{($-$)-Morphine}
980 SMILES: \verb|CN1CC[C@]23c4c5ccc(c4O[C@H]2[C@H](C=C[C@H]3[C@H]1C5)O)O|
981 \end{figure}
982
983 \begin{figure}[ht]
984 \centering
985 \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}
986 \caption{Brevetoxin A}
987 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|
988 \end{figure}
989
990 %<*en>
991 However, the results are sometimes undesirable and may also be
992 different depending on version numbers.
993 Here are some examples:
994 %</en>
995 %<*ja>
996 しかし,時には結果が望ましくないことがあり,
997 また使用するバージョン番号によって出力が異なることがあります。
998 いくつかの例を示します:
999 %</ja>
1000
1001 \clearpage
1002
1003 \begin{figure}[p]
1004 Cephalostatin-1 (Example from \href{http://en.wikipedia.org/wiki/Simplified_molecular-input_line-entry_system}{Wikipedia}): \\
1005 \verb|C[C@@](C)(O1)C[C@@H](O)[C@@]1(O2)[C@@H](C)[C@@H]3CC=C4[C@]3(C2)C(=O)C[C@H]5[C@H]4CC[C@@H](C6)[C@]5(C)Cc(n7)c6nc(C[C@@]89(C))c7C[C@@H]8CC[C@@H]%10[C@@H]9C[C@@H](O)[C@@]%11(C)C%10=C[C@H](O%12)[C@]%11(O)[C@H](C)[C@]%12(O%13)[C@H](O)C[C@@]%13(C)CO|
1006 \begin{center}
1007 \includegraphics[scale=0.85]{figures/Mac231-Cephalostatin-1.pdf}
1008 \caption{Cephalostatin-1 (figure from Open Babel for Mac 2.3.1)}
1009 \includegraphics[scale=0.5]{figures/Win232-Cephalostatin-1.pdf}
1010 \caption{Cephalostatin-1 (figure from Open Babel for Win 2.3.2)}
1011 \end{center}
1012 \end{figure}
1013
1014 \begin{figure}[p]
1015 Sesamin: \verb|c1cc2c(cc1C3C4COC(C4CO3)c5ccc6c(c5)OCO6)OCO2|
1016 \begin{center}
1017 \centering
1018 \includegraphics[scale=0.5]{figures/Mac231-sesamin-normal.pdf}
1019 \includegraphics[scale=0.5]{figures/Mac231-sesamin-gen2d.pdf}
1020 \caption{Sesamin (figures from Open Babel for Mac 2.3.1; Normal and \Lcode{--gen2d})}
1021 \includegraphics[scale=0.5]{figures/Win232-sesamin-normal.pdf}
1022 \includegraphics[scale=0.5]{figures/Win232-sesamin-gen2d.pdf}
1023 \caption{Sesamin (figures from Open Babel for Win 2.3.2; Normal and \Lcode{--gen2d})}
1024 \end{center}
1025 \end{figure}
1026
1027 \clearpage
1028
1029 %<*en>
1030 Also, Open Babel may generate wrong structures from SMILES notations.
1031 Here we can see the formula generated from a SMILES notation lacks one double bond.
1032 %</en>
1033 %<*ja>
1034 また,Open BabelはSMILES表記から誤った構造式を生成することもあります。
1035 ホタルルシフェリンの図で,SMILES表記から生成した構造式には
1036 二重結合が一つ欠けています。
1037 %</ja>
1038 \begin{figure}[ht]
1039 \centering
1040 \includegraphics[scale=0.6]{figures/Exact-FireflyLuciferin.pdf}
1041 \caption{Firefly luciferin: exact structure from ChemSpider ID 4588411}
1042 \includegraphics[scale=0.6]{figures/Win232-FireflyLuciferin.pdf}
1043 \caption{Firefly luciferin?: output from Open Babel for Win 2.3.2}
1044 \smilesobabel*[width=66mm]{C1[C@@H](N/C(=c\2/nc3c(=CC(=O)C=C3)s2)/S1)C(=O)O}
1045 \caption{Firefly luciferin?: output from current Open Babel}
1046 SMILES: \verb|C1[C@@H](N/C(=c\2/nc3c(=CC(=O)C=C3)s2)/S1)C(=O)O|
1047 \end{figure}
1048
1049 %<*en>
1050 We can avoid all these problems by using \verb|\chemobabel| with \verb|.mol| or
1051 \verb|.cdx| files, instead of \verb|\smilesobabel|.
1052 However, the fact that many complex structures can be generated from
1053 only one character string is very interesting, isn't it?
1054 %</en>
1055 %<*ja>
1056 このような問題点は全て \verb|.mol| または \verb|.cdx| を
1057 用意して \verb|\chemobabel| を利用することで回避できます。
1058 とはいえ,ただの文字列から複雑な構造式を生成しうるということ自体,
1059 おもしろいとは思いませんか?
1060 %</ja>
1061
1062 \clearpage
1063
1064 %<*en>
1065 \section{Note for Compatibility}
1066 %</en>
1067 %<*ja>
1068 \section{互換性に関する注意}
1069 %</ja>
1070
1071 %<*en>
1072 \subsection{Advantages of \Lpack{chemobabel}}
1073 %</en>
1074 %<*ja>
1075 \subsection{\Lpack{chemobabel}パッケージの有利な点}
1076 %</ja>
1077
1078 %<*en>
1079 The macros \verb|\smiles| (written by Noel O'Boyle \cite{NOB1}) and
1080 \verb|\obabel| (depends on \Lpack{graphvizObabel.sty} by
1081 Jakob Lykke Andersen's \cite{JLA}) can be used as follows:
1082 %</en>
1083 %<*ja>
1084 Noel O'Boyleさんによる \verb|\smiles| \cite{NOB1} あるいは
1085 Jakob Lykke Andersenさんによる\Lpack{graphvizObabel.sty}が
1086 提供する \verb+\obabel+ \cite{JLA} は以下のようにして使うことになっています:
1087 %</ja>
1088 \begin{verbatim}
1089 %% ----- for \smiles command -----
1090 \newcounter{smilescounter}
1091 \setcounter{smilescounter}{1}
1092 \newcommand{\smiles}[1]{
1093 \immediate\write18{obabel -:"#1" -O smilesimg\arabic{smilescounter}.png}
1094 \includegraphics{smilesimg\arabic{smilescounter}.png}
1095 \addtocounter{smilescounter}{1}
1096 }
1097 ...
1098 \smiles{CCO}
1099 %% -----
1100 \end{verbatim}
1101 \begin{verbatim}
1102 %% ----- for \obabel command -----
1103 \usepackage{graphvizObabel}
1104 ...
1105 \obabel[scale=0.6]{CCO}
1106 %% -----
1107 \end{verbatim}
1108 %<*en>
1109 However, \verb|\smiles| command creates raster graphics (.png) and
1110 has no options to pass to \verb|\includegraphics|, and \verb|\obabel| command
1111 sometimes does not work because of lack of file extension (.pdf) and
1112 possibility of giving errors with empty optional parameters.
1113 These problems are solved in \verb|\smilesobabel|.
1114 %</en>
1115 %<*ja>
1116 しかし,\verb|\smiles| はラスター画像 (.png) を生成して
1117 かつ \verb|\includegraphics| に渡すオプションを扱えず,\verb|\obabel| は
1118 拡張子 (.pdf) が欠落していたりオプション引数が空の場合にエラーが発生したり
1119 という理由で正しく処理できない可能性があります。
1120 これらの問題は \verb|\smilesobabel| では解決されています。
1121 %</ja>
1122
1123 \clearpage
1124
1125 %<*en>
1126 \section{Limitations and Alternatives}
1127 %</en>
1128 %<*ja>
1129 \section{この方法の限界と代替案}
1130 %</ja>
1131
1132 %<*en>
1133 This method relies on Open Babel for generating structural formulas,
1134 even without drawing anything by yourself.
1135 Of course you can modify and customize these structures to some extent,
1136 but this method will not be suitable for fine control of the output.
1137 Also, computer-generated formulas may sometimes be unnatural and undesirable.
1138 Therefore this method will be useful only when you need a simple method
1139 for inserting structural formulas with minimal modification.
1140 If you are not satisfied with the output, consider using {\XyMTeX} or
1141 \Lpack{chemfig} packages instead.
1142
1143 I also found following packages which can be used for similar purpose:
1144 %</en>
1145 %<*ja>
1146 この方法はOpen Babelに依存して構造式を生成しており,
1147 一切自分で構造式を描画することなく済ませることさえ可能です。
1148 もちろんある程度はそれらの構造を修正したりカスタマイズしたりできますが,
1149 この方法は出力の緻密な調節には不向きでしょう。
1150 また,コンピュータによって生成される構造式は時に見た目が不自然で,
1151 好ましくない場合もあるかもしれません。
1152 したがって,この方法は構造式の出力を完全に制御したいという意図がなく,
1153 構造式を簡便に挿入したい場合にのみ役に立つでしょう。
1154 出力に満足できない場合は,\XyMTeX や\Lpack{chemfig}のようなパッケージを
1155 代わりに使うことをご検討ください。
1156
1157 同様の目的を達成するために使えそうなパッケージとして,
1158 以下のようなものもあります:
1159 %</ja>
1160 \begin{itemize}
1161 \item \href{http://www.ctan.org/pkg/mol2chemfig}{\Lpack{mol2chemfig}}:
1162 convert chemical structures from MDL molfile format
1163 to \Lpack{chemfig} source code
1164 \end{itemize}
1165
1166 \clearpage
1167
1168 %<*en>
1169 \section{Technical information}
1170 %</en>
1171 %<*ja>
1172 \section{技術情報}
1173 %</ja>
1174 \label{detail}
1175
1176 %<*en>
1177 According to
1178 \href{http://www.daylight.com/meetings/summerschool98/course/dave/smiles-intro.html}{SMILES Tutorial},
1179 special characters are used in SMILES syntax are the followings:
1180 %</en>
1181 %<*ja>
1182 SMILES表記法に使われる特殊文字の一覧は,
1183 \href{http://www.daylight.com/meetings/summerschool98/course/dave/smiles-intro.html}{SMILES Tutorial}%
1184 によると以下のようです。
1185 %</ja>
1186 \begin{itemize}
1187 \item Roman alphabets: \verb|A-Z|, \verb|a-z|
1188 \item Numbers: \verb|1-10|
1189 \item Brackets: \verb|[ ] ( )|
1190 \item Others:
1191 \begin{itemize}
1192 \item \verb|*| (unspecified atomic number)
1193 \item \verb|.| (disconnection)
1194 \item \verb|+| (charge sign)
1195 \item \verb|-| (single bond or charge sign)
1196 \item \verb|=| (double bond)
1197 \item \verb|#| (triple bond)
1198 \item \verb|$| (quadruple bond)
1199 \item \verb|:| (aromatic bond)
1200 \item \verb|%| (used when more than 10 ring closures)
1201 \item \verb|/|, \verb|\| (configuration around double bonds)
1202 \item \verb|@| (tetrahedral chirality)
1203 \item \verb|>| (reaction)
1204 \end{itemize}
1205 \end{itemize}
1206
1207 %<*en>
1208 It is important to prevent these characters from being translated as
1209 \LaTeX\ special characters.
1210 However, a backslash (\verb|\|) is a default escape character in \LaTeX,
1211 and a percent symbol (\verb|%|) also has a special meaning as a comment character.
1212 In \Lpack{chemobabel} (higher than v0.7), all these characters are
1213 handled properly by changing category codes temporarily (like \verb+\verb+). \\
1214 %</en>
1215 %<*ja>
1216 これらの文字が\LaTeX における特殊文字として解釈されることを防ぐ
1217 必要がありますが,バックスラッシュ \verb|\| はデフォルトの
1218 エスケープ文字であり,またパーセント記号 \verb|%| もコメント文字と
1219 しての特殊な意味を持っています。
1220 \Lpack{chemobabel} v0.7以上では,カテゴリーコードを一時的に変更することで
1221 これらすべての文字を適切に扱うようになっています(\verb+\verb+と同様の手法)。
1222 %</ja>
1223
1224 \clearpage
1225
1226 %<*en>
1227 \section{Version History}
1228 %</en>
1229 %<*ja>
1230 \section{更新履歴}
1231 %</ja>
1232
1233 \begin{table}[h]
1234 \centering
1235 \begin{tabular}{ll}
1236 2014/12/01 v0.1 & Made public as \Lpack{smilesobabel.sty} \\
1237 2014/12/02 v0.2 & Add options which can be passed to obabel. \\
1238 2014/12/07 v0.3 & Change name of package: \Lpack{chemobabel.sty} \\
1239 & Images are stored in \Lcode{chemobabelimgdir}. \\
1240 & Add \verb|\chemobabel| command. \\
1241 2014/12/09 v0.4 & Fix a bug: (Thanks: Yusuke Terada) \\
1242 & Extra spaces at the end of lines are removed. \\
1243 2014/12/20 v0.5 & Add \verb|extract| option. \\
1244 2015/06/29 v0.6 & Improve warning messages. \\
1245 2015/08/26 v0.7 & Solve \verb|\catcode|-related problems in \verb|\smilesobabel|. \\
1246 2015/08/27 v0.8 & Improve \verb|\smilesobabel| a little. \\
1247 2015/08/28 v0.9 & Improve \verb|\smilesobabel|: (Thanks: ZR) \\
1248 & Exclude $\varepsilon$-\TeX\ dependency. \\
1249 2015/08/29 v0.9a & Improve \verb|\chemobabel| a little. \\
1250 2016/01/06 v0.9b & Support Lua\TeX-0.85.0 and later versions. \\
1251 2016/02/09 v0.9c & Fix a bug; forgotten in v0.9b. \\
1252 2016/02/28 v0.9d & Add \verb|eps| and \verb|pdf| options. \\
1253 2016/03/07 v0.9e & Add \verb|librsvg| and \verb|inkscape| options. \\
1254 2016/10/23 v0.9f & Incorporate \verb|extract| option into main package. \\
1255 2018/01/23 v0.9g & Minor refactor of code. \\
1256 2022/09/11 v0.9h & Support Inkscape version 1.0 command line syntax. \\
1257 2022/09/12 v0.9i & Crop images before inclusion, add \verb|nocrop| option. \\
1258 2022/09/19 v0.9j & Check shell-escape status to show better error message. \\
1259 & This is the first release on CTAN! \\
1260 2022/10/09 v0.9k & Add \verb|\chemobabel*| and \verb|\smilesobabel*|. \\
1261 & Warn if a user need to run another \LaTeX. \\
1262 & Improve \verb|[extract]| to take over user-given package options. \\
1263 2022/10/22 v0.9l & Default to EPS mode if PDF inclusion is unsupported by the driver. \\
1264 & Default \verb|clip| for image inclusion. \\
1265 \end{tabular}
1266 \end{table}
1267
1268 \textbf{Important!}
1269 \begin{itemize}
1270 \item In Version 0.2, the number of parameters set in \verb|\smilesobabel| is changed!
1271 \item From Version 0.3, the package name is changed to \Lpack{chemobabel.sty}.
1272 \item From Version 0.7, the \verb|\catcode|-related workaround is rather harmful.
1273 \end{itemize}
1274
1275 \clearpage
1276
1277 \begin{thebibliography}{9}
1278 \bibitem{NOB1}
1279 \href{http://baoilleach.blogspot.jp/2012/03/cheer-up-your-latex-with-smiles-support.html}{Cheer up your \LaTeX\ with SMILES support} -- Noel O'Blog
1280 \bibitem{NOB2}
1281 \href{http://baoilleach.blogspot.jp/2012/04/cheer-up-your-latex-with-smiles-support.html}{Cheer up your \LaTeX\ with SMILES support II} -- Noel O'Blog
1282 \bibitem{JLA}
1283 \href{http://imada.sdu.dk/~jlandersen/}{\LaTeX: Graphviz and OpenBabel} -- Jakob Lykke Andersen
1284 \bibitem{OKU}
1285 \href{http://oku.edu.mie-u.ac.jp/tex/mod/forum/discuss.php?d=1411}{文章内の画像のみを表示する方法} -- \TeX\ Forum \\
1286 (How to extract only figures in \LaTeX\ source)
1287 \bibitem{ACE1}
1288 \href{http://acetaminophen.hatenablog.com/entry/2014/11/02/130624}{化学構造式を\TeX で(1):自動化による簡単生成} -- Acetaminophen's diary \\
1289 (Chemical Structural Formula in \LaTeX\ (1): An Easy Method by Auto-generation)
1290 \bibitem{ACE2}
1291 \href{http://acetaminophen.hatenablog.com/entry/2014/11/02/130624}{化学構造式を\TeX で(2):自動化の注意点と解消法} -- Acetaminophen's diary \\
1292 (Chemical Structural Formula in \LaTeX\ (2): Important Notes for Auto-generation and Solution)
1293 \bibitem{ACE3}
1294 \href{http://acetaminophen.hatenablog.com/entry/2014/11/05/135927}{化学構造式を\TeX で(3):補足事項} -- Acetaminophen's diary \\
1295 (Chemical Structural Formula in \LaTeX\ (3): Supplement)
1296 \end{thebibliography}
1297
1298 \noindent
1299 \textbf{Note}: \href{http://acetaminophen.hatenablog.com/}{Acetaminophen's diary} is my own blog! (Sorry, but only in Japanese)
1300
1301 I added a post about this package on the 8th day of \href{http://www.adventar.org/calendars/553}{\TeX\ \& \LaTeX\ Advent Calendar 2014} (in Japanese):
1302 \begin{itemize}
1303 \item \href{http://acetaminophen.hatenablog.com/entry/2014/12/08/053519}{誰でも簡単! 化学構造式を\LaTeX に取り込むパッケージ} -- Acetaminophen's diary \\
1304 (An easy way to insert chemical structural formulas into \LaTeX\ documents)
1305 \end{itemize}
1306
1307 \end{document}