diff options
author | Norbert Preining <preining@logic.at> | 2007-11-16 10:51:37 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2007-11-16 10:51:37 +0000 |
commit | a0556f51c14da4034ebba3a3967f525d4be2d127 (patch) | |
tree | 467768be8feb6a18b407d27f351888815c6944dc /Master/texmf-dist/source/latex/chemscheme/chemscheme.dtx | |
parent | 2925ee6e742b7ddfa9f1bf3c75dd98b7d8ce0f36 (diff) |
update chemscheme v1.3 from ctan
git-svn-id: svn://tug.org/texlive/trunk@5446 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/chemscheme/chemscheme.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/chemscheme/chemscheme.dtx | 1235 |
1 files changed, 928 insertions, 307 deletions
diff --git a/Master/texmf-dist/source/latex/chemscheme/chemscheme.dtx b/Master/texmf-dist/source/latex/chemscheme/chemscheme.dtx index 89d7b0c8b52..1efcbc22dc8 100644 --- a/Master/texmf-dist/source/latex/chemscheme/chemscheme.dtx +++ b/Master/texmf-dist/source/latex/chemscheme/chemscheme.dtx @@ -3,32 +3,138 @@ % Copyright (C) 2007 by % Joseph Wright <joseph.wright@morningstar2.co.uk> % -% Released under the GNU General Public License v2 -% See http://www.gnu.org/licenses/gpl.txt +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either +% version 1.3 of this license or (at your option) any later +% version. The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of +% LaTeX version 2003/12/01 or later. % -% This work consists of the main source file chemscheme.dtx -% and the derived files chemscheme.sty and chemscheme.pdf; -% also included is the ChemDraw source file chemscheme.cdx +% This work has the LPPL maintenance status ``maintained.'' % +% The current maintainer of this work is Joseph Wright. +% +% This work consists of the source file chemscheme.dtx and +% scheme.cdx +% and the derived files chemscheme.ins, +% chemscheme.sty, +% chemscheme.pdf, +% scheme-one.eps and +% scheme-two.eps +% +% Unpacking: +% (a) If chemscheme.ins is present: +% tex chemscheme.ins +% (b) Without chemscheme.ins: +% tex chemscheme.dtx +% (c) If you use LaTeX to generate files: +% latex \let\install=y\input{chemscheme.dtx} +% +% Documentation: +% (a) Without write18 enabled: +% latex chemscheme.dtx +% (Comment out "inactive" line in driver where indicated) +% latex chemscheme.dtx +% dvips -o chemscheme-pics.ps chemscheme.dvi +% ps2pdf chemscheme-pics.ps +% bibtex8 --wolfgang chemscheme.aux +% makeindex -s gind.ist chemscheme.idx +% makeindex -s gglo.ist -o chemscheme.gls chemscheme.glo +% pdflatex chemscheme.dtx +% makeindex -s gind.ist chemscheme.idx +% makeindex -s gglo.ist -o chemscheme.gls chemscheme.glo +% pdflatex chemscheme.dtx +% (b) With write18 enabled: +% latex chemscheme.dtx +% (Comment out "inactive" line in driver where indicated) +% latex chemscheme.dtx +% pdflatex chemscheme.dtx +% bibtex8 --wolfgang chemscheme.aux +% pdflatex chemscheme.dtx +% pdflatex chemscheme.dtx +% +% Installation: +% Copy chemscheme.sty to a location searched by TeX, and +% if required by your TeX installation, run the appropriate +% command to build a hash of files (texhash, mpm --update-db, +% etc.) +% +% Note: +% The jawltxdoc.sty file is not needed for installation, +% only for building the documentation. It may be deleted. +% +%<*ignore> +% This is all taken verbatim from Heiko Oberdiek's packages +\begingroup + \def\x{LaTeX2e}% +\expandafter\endgroup +\ifcase 0\ifx\install y1\fi\expandafter + \ifx\csname processbatchFile\endcsname\relax\else1\fi + \ifx\fmtname\x\else 1\fi\relax +\else\csname fi\endcsname +%</ignore> +%<*install> +\input docstrip.tex +\keepsilent +\askforoverwritefalse +\preamble + ---------------------------------------------------------------- + The chemscheme package --- Support for chemical schemes + Maintained by Joseph Wright + E-mail: joseph.wright@morningstar2.co.uk + Released under the LaTeX Project Public License v1.3 or later + See http://www.latex-project.org/lppl.txt + ---------------------------------------------------------------- + +\endpreamble +\Msg{Generating chemscheme files:} +\usedir{tex/latex/contib/chemscheme} +\generate{\file{\jobname.ins}{\from{\jobname.dtx}{install}} + \file{\jobname.sty}{\from{\jobname.dtx}{package}} + \file{jawltxdoc.sty}{\from{\jobname.dtx}{jawltxdoc}} +} +\nopreamble\nopostamble +\usedir{doc/latex/chemscheme} +\generate{\file{scheme-one.eps}{\from{chemscheme.dtx}{scheme}} + \file{scheme-two.eps}{\from{chemscheme.dtx}{scheme,labels}} + \file{chemscheme.bib}{\from{chemscheme.dtx}{bib}} +} +\endbatchfile +%</install> +%<*ignore> +\fi +% Will Robertson's trick +\immediate\write18{makeindex -s gind.ist -o \jobname.ind \jobname.idx} +\immediate\write18{makeindex -s gglo.ist -o \jobname.gls \jobname.glo} +\immediate\write18{dvips -o \jobname-pics.ps \jobname.dvi} +\immediate\write18{ps2pdf \jobname-pics.ps} +%</ignore> %<*driver> +\PassOptionsToClass{a4paper}{article} \documentclass{ltxdoc} \EnableCrossrefs \CodelineIndex \RecordChanges %\OnlyDescription -\usepackage[T1]{fontenc} -\usepackage[english,UKenglish]{babel} -\usepackage{mathpazo,booktabs,array,url,graphicx,unitsdef,courier} -\usepackage[scaled=0.95]{helvet} -\usepackage[final]{microtype} -\usepackage{\jobname} +% The various formatting commands used in this file are collected +% together in |jawltxdoc|. +\usepackage{jawltxdoc} +% A bit of one-off trickery for this package +% Use the method described in the documentation if you +% want to compile this DTX using PDFLaTeX +\usepackage[final% +% Comment out the next line when using PDFLaTeX after the initial +% LaTeX run! +% ,inactive% + ]{pst-pdf} \begin{document} \DocInput{\jobname.dtx} \end{document} %</driver> % \fi % -% \CheckSum{122} +%\CheckSum{273} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -50,14 +156,15 @@ % % \changes{v1.0}{2007/07/21}{Initial public release} % \changes{v1.1}{2007/08/05}{Added float centring code} +% \changes{v1.2}{2007/08/18}{Removed \texttt{chapter} option} +% \changes{v1.2}{2007/08/18}{Improved emulation of standard float +% types} +%\changes{v1.2a}{2007/09/19}{License changed from GPL to LPPL} +%\changes{v1.2a}{2007/09/19}{Documentation for PDF use added} +%\changes{v1.3}{2007/10/04}{Improved French and German +% \texttt{babel} support} % -% \DoNotIndex{\@ifclassloaded,\@undefined,\chapter,\CNlabel} -% \DoNotIndex{\CNlabelsub,\compound,\DeclareOption,\def,\else} -% \DoNotIndex{\floatname,\fi,\global,\ifx,\let,\listof,\MessageBreak} -% \DoNotIndex{\NeedsTeXFormat,\newcommand,\newfloat,\newif} -% \DoNotIndex{\newlistof,\PackageWarning,\ProcessOptions,\protect} -% \DoNotIndex{\ProvidesPackage,\psfrag,\raggedleft,\RequirePackage} -% \DoNotIndex{\relax,\space,\textsf} +%\DoNotIndex{} % % \title{\texttt{chemscheme} --- Support for chemical schemes% % \thanks{This file describes version \fileversion, last revised @@ -68,19 +175,20 @@ % % \maketitle % -% \begin{abstract} -% +%\begin{abstract} % The |chemscheme| package consists of two parts, both related to % chemical schemes. The package adds a |scheme| float type to the % LaTeX default types |figure| and |table|. The |scheme| float type % acts in the same way as those defined by the LaTeX kernel, but is % intended for chemical schemes. The package also provides a method % for adding automatic chemical numbering to schemes. +%\end{abstract} % -% \end{abstract} -% -% \section{Introduction} +%\begin{multicols}{2} +%\tableofcontents +%\end{multicols} % +%\section{Introduction} % By default, LaTeX defines two float types, |figure| and |table|. % Synthetic chemists make heavy use of schemes, which need a |scheme| % float type. This is provided by |chemscheme|, in a manner @@ -90,79 +198,84 @@ % There are a number of LaTeX packages which cover this area, most % notably |bpchem| and |chemcompounds|. However, adding numbers % automatically to schemes is not covered by any existing package. -% The |chemescheme| package seeks to rectify this. -% -% \section{Floating schemes} +% The |chemscheme| package seeks to rectify this. +%\floatcontentscentre % -% \subsection{Basic use} -% -% \DescribeEnv{scheme} +%\section{Floating schemes} +%\subsection{Basic use} +%\DescribeEnv{scheme} % The package provides a new float type, scheme, accessed in the -% usual way. So, issuing the following commands: +% usual way. +%\begin{LaTeXexample}[\typesetfloatexample] % \begin{scheme}[ht] -% \centering -% \includegraphics{scheme-one}\\ +% \includegraphics{scheme-one} % \caption{A scheme with no compound numbers.} -% \label{scheme-one} % \end{scheme} -% \begin{verbatim} -% \begin{scheme}[ht] -% \centering -% \includegraphics{scheme-one}\\ -% \caption{A scheme with no compound numbers.} -% \label{scheme-one} -% \end{scheme} -% \end{verbatim} -% will lead to the appearance of a scheme as requested -% (Scheme~\ref{scheme-one}). By default, the positioning of |scheme| -% floats follows the standard LaTeX system (positioning at the top -% of a page is preferred). As shown in the example, the use of -% positional modifiers is allowed. The |float| package is loaded by -% |chemscheme|, allowing the use of the |[H]| positional directive, -% meaning \emph{really} here.\footnote{|memoir| users should note -% that |float| cannot be used with this document class. The internal -% |memoir| system for float placement is thus in use in this case.} -% Labelling and referencing schemes follows the LaTeX conventions. -% So for example, to reference Scheme~\ref{scheme-one}, you type -% \begin{verbatim} -% Scheme~\ref{scheme-one} -% \end{verbatim} +%\end{LaTeXexample} +% The |scheme| float is designed to behave in the same way as the +% standard LaTeX float environments |figure| and |table|. Thus +% schemes will be placed at the top of a page, where possible. As +% shown in the example, the use of positional modifiers is allowed. +% Labelling and referencing schemes also follows the LaTeX +% conventions. |chemscheme| works hard to emulate the document class +% in use, and so the exact behaviour will depend on whether the +% standard classes, \textsc{koma-script} or |memoir| are being used. % % \DescribeMacro{\listofschemes} +% \DescribeMacro{\listschemename} % To match the \cmd{\listoffigures} and \cmd{\listoftables} macros % provided by the LaTeX kernel, |chemscheme| provides a % \cmd{\listofschemes} command. This works in the same way as the -% kernel commands, taking a single optional argument \oarg{Title}, -% which by default is ``List of Schemes.'' The output of the -% \cmd{\listofschemes} command is illustrated below. +% kernel commands, with the default text stored in the macro +% \cmd{\listschemename}. Users upgrading from version 1.1 should +% note the change of macro name (from \cmd{\listscheme}). This +% is to bring |chemscheme| into line with the LaTeX kernel +% naming convention. Also notice that \cmd{\listofschemes} no longer +% accepts an optional argument. The standard output is illustrated +% below. +%\begin{LaTeXexample}[\typesetcodeandexample] % \listofschemes +%\end{LaTeXexample} % -% \subsection{Altering the defaults} +%\subsection{Altering the defaults} % % For users of the standard class files or the \textsc{koma-script} % bundle, the |float| package is used to create the new float type. % Thus the usual |float| commands can be used to modify the behaviour % as desired. Users of |memoir| will have slightly different commands % available, as |memoir| implements its own new float mechanism, -% which is used in that case. Schemes may be numbered within chapters -% (Scheme~1.1, Scheme~1.2, \emph{etc.}~by loading the package with the -% [chapter] option. +% which is used in that case. Anything that you can do for a +% standard float, you should be able to to do for a scheme, and it +% should behave in the same way as a figure or a table. Please +% let the package maintainer know of any bugs in this support. % % \DescribeMacro{\schemename} -% \DescribeMacro{\listschemes} -% Two macros are provided to allow the user to re-define the name of -% schemes and the title of the list of schemes in a consistent manner -% (independent of document class). Thus \cmd{\schemename} contains -% the text used in scheme captions (by default \schemename), and -% \cmd{\listschemes} contains the title of the scheme list (by -% default \listschemes). Both may be freely re-defined. +% \cmd{\schemename} contains the text used in scheme captions (by +% default \schemename). This is used in the same manner as +% \cmd{\figurename} or \cmd{\tablename} to set up the text used in +% scheme captions. +%\begin{LaTeXexample}[\typesetfloatexample] +% \renewcommand*{\schemename}{Illustration} +% \begin{scheme}[ht] +% \includegraphics{scheme-one} +% \caption{A scheme that is not a Scheme!} +% \end{scheme} +%\end{LaTeXexample} +% ^^A The name is reset to normal after the example +%\renewcommand*{\schemename}{Scheme} % -% \section{Horizontal positioning of all floats} +%\subsection{\texttt{babel} support} +% Schemes are provided with some support for |babel|. Currently, in +% addition to English, |chemscheme| provides alternatives for +% \cmd{\schemename} and \cmd{\listschemename} in French and German. +% Users of other languages are encouraged to supply suitable +% translations for inclusion in future versions of |chemscheme|. % -% \DescribeMacro{\floatcontentscentre} -% \DescribeMacro{\floatcontentscenter} -% \DescribeMacro{\floatcontentsleft} -% \DescribeMacro{\floatcontentsright} +%\section{Horizontal positioning of all floats} +%\DescribeMacro{\floatcontentscentre} +%\DescribeMacro{\floatcontentscenter} +%\DescribeMacro{\floatcontentsleft} +%\DescribeMacro{\floatcontentsright} % The LaTeX default is to position all float contents flush-left. % There is no ``hook'' provided to alter this. The |chemscheme| % packages therefore provides commands to align all float contents @@ -172,9 +285,22 @@ % \cmd{\floatcontentscenter} is also available). The default % behaviour is restored using the command \cmd{\floatcontentsleft}. % Finally, \cmd{\floatcontentsright} is provided for use if needed. -% notice that the float positioning commands should be given +% Notice that the float positioning commands should be given % \emph{outside} floating environments, and apply to all subsequent % floats. +%\begin{LaTeXexample}[\typesetfloatexample] +% \floatcontentsleft +% \begin{scheme}[ht] +% \includegraphics{scheme-one} +% \caption{A flush-left scheme.} +% \end{scheme} +% \floatcontentsright +% \begin{scheme}[ht] +% \includegraphics{scheme-one} +% \caption{A flush-right scheme.} +% \end{scheme} +% \floatcontentscentre +%\end{LaTeXexample} % % It is important to note that the positioning mechanism used here % relies on a low-level hack of the LaTeX kernel. This has been @@ -182,10 +308,8 @@ % and the \textsc{koma-script} bundled. Other document classes may % not give the desired behaviour. % -% \section{Reference numbers in graphics} -% -% \subsection{Background} -% +%\section{Reference numbers in graphics} +%\subsection{Background} % There are a number of packages available on \textsc{ctan} for % tracking compound reference numbers. The two with the most up to % date and comprehensive features are |bpchem| and |chemcompounds|. @@ -195,151 +319,276 @@ % adapt schemes to match any changes in numbering. % % The |chemscheme| package provides a mechanism for rectifying this -% issue, provided that \emph{compilation occurs in LaTeX (DVI) mode -% and not using pdfLaTeX}.\footnote{Of course, both may be using the -% pdfTeX engine; it is the output mode that is important.} +% issue. The package makes use of the |psfrag| package, which means +% that it can only directly produce DVI output (using LaTeX). +% However, direct PDF output using PDFLaTeX is possible: see +% Section~\ref{subsec:pdf}. % -% \subsection{Usage} +%\DescribeMacro{\chemschemeref} +%\DescribeMacro{\chemschemerefsub} +% Users upgrading from v.2 should note that ``chem'' has been removed +% from the start of most macro names. The main referencing commands +% \cmd{\chemschemeref} and \cmd{\chemschemerefsub} are retained for +% backward compatibility. % +%\subsection{Usage} % Getting automated numbers into schemes is a two step procedure. In % the first step, schemes (or other graphics) should be prepared as -% normal and saved as encapsulated postscript (\textsc{eps}) files -% The most popular chemistry drawing package, \textsc{ChemDraw}, -% is able to do this from the \texttt{Save As \ldots} dialog. -% \DescribeMacro{\chemschemerefmarker} -% The positions where the auto-labels should be positioned have to be -% marked in the \textsc{eps} file. The marker should consist of an -% ``indicator'' that the text is to be replaced, followed by a -% reference number or letter. The ``indicator'' text should be the -% same in all graphics; it is stored in \cmd{\chemschemerefmarker}, -% and has default value \textsf{\chemschemerefmarker}. Thus the -% graphics should contain labels \textsf{\chemschemerefmarker1}, -% \textsf{\chemschemerefmarker2}, \emph{etc.} A suitable unmodified -% graphic is shown in Scheme~\ref{scheme-two-uned}. +% normal and saved as encapsulated postscript (EPS) files The most +% popular chemistry drawing package, \textsc{ChemDraw}, is able to do +% this from the \texttt{Save As \ldots} dialog. +%\DescribeMacro{\schemerefmarker} +% The positions where the auto-labels should be have to be marked in +% the EPS file. The marker should consist of an ``indicator'' that +% the text is to be replaced, followed by a reference number or +% letter. For automated substitution, the ``indicator'' text should +% be the same in all graphics; the value it is stored in +% \cmd{\schemerefmarker}, and has default value +% \textsf{\schemerefmarker}. Thus the graphics should contain labels +% \textsf{\schemerefmarker1}, \textsf{\schemerefmarker2}, \emph{etc}. +% A suitable unmodified graphic is shown in in the next example. +%\begin{LaTeXexample}[\typesetfloatexample] % \begin{scheme}[ht] -% \centering -% \includegraphics{scheme-two}\\ +% \includegraphics{scheme-two} % \caption{A scheme with temporary compound numbers.} -% \label{scheme-two-uned} % \end{scheme} +%\end{LaTeXexample} +% The value of \cmd{\schemerefmarker} may be altered as normal, +% so for example to use \textsf{XXX} as the indicator for +% replacement in all graphics, you would execute: +%\begin{LaTeXexample}[\typesetcodeonly] +% \renewcommand*{\chemeschemerefmarker}{XXX} +%\end{LaTeXexample} % -% The value of \cmd{\chemschemerefmarker} may be altered as normal -% using \cmd{\renewcommand}, so for example to use \textsf{XXX} -% as the indicator for replacement, you would execute -% |\renewcommand{\chemeschemerefmarker}{XXX}|. -% -% \DescribeMacro{\chemschemeref} -% In the second step, the command \cmd{\chemschemeref} is used to +%\DescribeMacro{\schemeref} +% In the second step, the command \cmd{\schemeref} is used to % indicate the mapping of the temporary markers to the -% automatically-managed numbering. The syntax of the command -% is \cmd{\chemschemeref}\marg{temp-marker}\marg{label}, where -% \meta{temp-marker} is the unique marker used in the graphic, -% and \meta{label} is the name assigned to the compound by the user. -% Each replacement requires a separate \cmd{\chemschemeref}, all -% of which should appear before the relevant \cmd{\includegraphics} -% command. Notice that \meta{temp-marker} only contains the -% unique part of the temporary marker. Thus using the default -% indicator \textsf{\chemschemerefmarker}, the \textsc{eps} file -% might contain \textsf{\chemschemerefmarker1} and \meta{temp-marker} -% would be \textsf{1}. +% automatically-managed numbering. The syntax of the command is +% \cmd{\chemschemeref}\oarg{temp-marker}\marg{label}, where +% \meta{temp-marker} is the marker used in the graphic, and +% \meta{label} is the name assigned to the compound by the user. By +% default, |chemscheme| will assume that \meta{temp-marker} consists +% of the marker plus a number, beginning at 1 and incrementing by 1 +% for each additional structure inside one float. Each replacement +% requires a separate \cmd{\chemschemeref}, all of which should +% appear before the relevant \cmd{\includegraphics} command. % % An example will make usage clearer. In the example used in this -% document, the starting material is given label |IMesHCl| and -% the product is called |IMes|. As is shown in -% Scheme~\ref{scheme-two-uned}, in the \textsc{eps} file these are -% labelled \textsf{TMP1} and \textsf{TMP2}, respectively. To relabel -% these as \CNlabel{IMesHCl} and \CNlabel{IMes}, the following is -% needed: +% document, the starting material is given label |IMesHCl| and the +% product is called |IMes|. As is shown in the next example, in the +% EPS file these are labelled \textsf{TMP1} and \textsf{TMP2}, +% respectively. The automated package defaults are used. +%\begin{LaTeXexample}[\typesetfloatexample] % \begin{scheme}[ht] -% \centering -% \chemschemeref{1}{IMesHCl} -% \chemschemeref{2}{IMes} -% \includegraphics{scheme-two}\\ +% \schemeref{IMesHCl} +% \schemeref{IMes} +% \includegraphics{scheme-two} % \caption{A scheme with automated compound numbers.} -% \label{scheme-two} % \end{scheme} -% \begin{verbatim} +%\end{LaTeXexample} +% With user-specified information on the text to be replaced, the +% entire text to be matched must be given.\footnote{In this example, +% this is redundant as the automated system will work fine.} +%\begin{LaTeXexample}[\typesetfloatexample] % \begin{scheme}[ht] -% \centering -% \chemschemeref{1}{IMesHCl} -% \chemschemeref{2}{IMes} -% \includegraphics{scheme-two}\\ -% \caption{A scheme with automated compound numbers.} -% \label{scheme-two} +% \schemeref[TMP1]{IMesHCl} +% \schemeref[TMP2]{IMes} +% \includegraphics{scheme-two} +% \caption{A scheme with explicitly numbered temporary labels.} % \end{scheme} -% \end{verbatim} -% It is important to notice that the chemical labels must be defined -% \emph{before} the use of \cmd{\chemschemeref}, or odd things may -% happen (most likely your document will not compile with strange -% errors). Also notice that the new label is centred on the middle of -% the temporary marker, with the same baseline. This should allow -% the user to obtain good alignment of labels and structures. +%\end{LaTeXexample} +% Notice that the new label is centred on the middle of the temporary +% marker, with the same baseline. This should allow the user to +% obtain good alignment of labels and structures. % -% \DescribeMacro{\chemschemerefsub} +%\DescribeMacro{\schemerefsub} % As described in Section~\ref{packages}, |chemscheme| supports % |bpchem|, which allows tracking of sub-labels (\textbf{1a}, -% \textbf{1b}, \emph{etc.}). To allow use of these in schemes, -% the \cmd{\chemschemerefsub} command is provided. This takes an -% additional argument \marg{sub-label}, which is used to generate -% the appropriate text. When used with |chemcompounds|, this command +% \textbf{1b}, \emph{etc.}). To allow use of these in schemes, the +% \cmd{\schemerefsub} command is provided. This takes an additional +% argument \marg{sub-label}, which is used to generate the +% appropriate text. When used with |chemcompounds|, this command % will gobble its arguments and issue a warning; no substitution will % take place. % -% \DescribeMacro{\chemschemerefformat} +%\DescribeMacro{\schemerefformat} % The format of chemical references is controlled by the underlying -% package, |bpchem| or |chemcompounds|. However, it is useful to -% be able to specify additional formatting for schemes. By default, +% package, |bpchem| or |chemcompounds|. However, it is useful to be +% able to specify additional formatting for schemes. By default, % |chemscheme| formats all reference numbers in a sans serif font. -% This is controlled by \cmd{\chemschemerefformat}. The additional -% formatting applied within schemes may be altered by redefining -% \cmd{\chemschemerefformat}. By careful choice of the font commands -% given here, good visual matching should be obtained between the -% automatically-generated labels and other text in the scheme. In -% this document, the \textsc{ChemDraw} source uses 10 point Arial, -% with the LaTeX sans serif font provided by the |helvet| package, -% loaded scaled to 95\percent, \emph{i.e.} -% \begin{verbatim} +% This is controlled by \cmd{\schemerefformat}. +%\begin{LaTeXexample}[\typesetfloatexample] +% % This needs the color or xcolor package loaded +% \renewcommand*{\schemerefformat} +% {\color{magenta}\textit} +% \begin{scheme}[ht] +% \schemeref{IMesHCl} +% \schemeref{IMes} +% \includegraphics{scheme-two} +% \caption{A scheme with altered label formatting.} +% \end{scheme} +%\end{LaTeXexample} +% The additional formatting applied within schemes may be altered by +% redefining \cmd{\schemerefformat}. By careful choice of the +% font commands given here, good visual matching should be obtained +% between the automatically-generated labels and other text in the +% scheme. In this document, the \textsc{ChemDraw} source uses 10 +% point Arial, with the LaTeX sans serif font provided by the +% |helvet| package, loaded scaled to 95\percent, \emph{i.e.}: +%\begin{LaTeXexample}[\typesetcodeonly] % \usepackage[scaled=0.95]{helvet} -% \end{verbatim} +%\end{LaTeXexample} % The \textsc{ChemDraw} file used to generate the example schemes -% is included with the package, as |chemscheme.cdx|. +% is included with the package as |chemscheme.cdx|. +% +%\subsection{\texttt{chemscheme} and PDFLaTeX\label{subsec:pdf}} +% The automatic substitution of numbers in graphics relies on the the +% |psfrag| package. This works with \textsc{PostScript} files, and +% cannot therefore be used with PDFLaTeX. However, all is not lost +% as the |pst-pdf| package provides a method for including +% \textsc{PostScript} files in a PDFLaTeX run. However, this is not +% automatic and some effort is needed by the user.\footnote{The rest +% of this section is based closely on an example by Stefan Pinnow.} +% The example below shows a example for using PDFLaTeX with +% |chemscheme|.\footnote{This example is saved as +% \texttt{example.tex} when this documentation is compiled.} +% ^^A This example is saved for the user as ``example.tex'' +%\edef\LaTeXexamplefile{example.tex} +%\begin{LaTeXexample}[\typesetcodeonly] +% \documentclass{article} +% \usepackage[T1]{fontenc} +% \usepackage{graphicx,chemscheme} +% % Remove inactive after the first LaTeX run +% \usepackage[inactive,final]{pst-pdf} +% \begin{document} +% \floatcontentscentre +% An example file for PDFLaTeX use. +% \begin{scheme} +% \schemeref{IMesHCl} +% \schemeref{IMes} +% \includegraphics{scheme-two} +% \caption{A scheme with automated compound numbers.} +% \label{sc:scheme-one} +% \end{scheme} +% \end{document} +%\end{LaTeXexample} +%\edef\LaTeXexamplefile{\jobname.tmp} % -% \subsection{Managing chemical numbering\label{packages}} +% First you need to run the file through LaTeX, so your package can +% make the replacements in the picture. Then you need another run +% through LaTeX with the |inactive| option |pst-pdf| removed so that +% the modified pictures are extracted.\footnote{You can simply do the +% first LaTeX run without loading \texttt{pst-pdf} at all, if you +% prefer.} Do not worry that you end up with a very odd looking DVI! +% Then you have to convert the extracted pictures to PDF by the +% following commands +%\begin{verbatim} +% dvips -o \jobname-pics.ps \jobname.dvi +% ps2pdf \jobname-pics.ps +%\end{verbatim} +% This converts the modified graphics into PDF format. After this, +% you can use PDFLaTeX as normal for your schemes. Notice that you +% will have to repeat the process if you need to modify the schemes +% or numbering in any way. % +%\subsection{Managing chemical numbering\label{packages}} % The |chemscheme| package can use one of two packages for management -% of chemical numbering. Both |bpchem| and |chemcompounds| are -% supported: |bpchem| is the default, and |chemcompounds| is requested -% by loading |chemescheme| with the [chemcompounds] option. Both -% packages have advantages: |bpchem| allows the tracking of -% sub-references (very common in organic chemistry), whilst +% of chemical numbering: |bpchem| and |chemcompounds|. As of v1.3, +% |chemcompounds| is the default package for managing reference +% numbers.\footnote{The change from \texttt{bpchem} is due to issues +% with \texttt{hyperref} support. The method used by \texttt{bpchem} +% to generate compound labels means that they are made into +% hyperlinks by \texttt{hyperref}, and therefore end up coloured when +% using the \texttt{colorlinks} option. This is unlikely to be the +% desired effect, and \texttt{chemcompounds} does not behave in this +% way.} Both packages have advantages: |bpchem| allows the tracking +% of sub-references (very common in organic chemistry), whilst % |chemcompounds| has a very well thought-out interface. It is % technically feasible to support both simultaneously, but this is % unlikely to have wide application. For this reason, |chemscheme| % loads only one package (depending on the user option given), and -% uses this package to provide numbering management. +% uses this package to provide numbering management. Both |bpchem| +% and |chemcompounds| provide a variety of methods for defining +% chemical labels. +% +%\section{Generating chemical schemes} +% +%\subsection{Overview} +% There are a number of ways of generating the graphical content of +% schemes. The choice of method will depend on what is available to +% the user, and how complex the schemes desired are. In this section, +% an overview of several approaches is given.\footnote{Thanks to +% Norwid-R.\ Behrnd for suggesting this section and giving a number +% of useful examples and tips.} The package author, who is a +% research worker in a university, favours using \textsc{ChemDraw} as +% it is regarded by many synthetic chemists as the best tool for this +% job. However, this is clearly overkill for users requiring a +% single diagram on a one-off basis. \textsc{ChemDraw} is also a +% commercial package running only under Windows and the MacOS. The +% following is necessarily somewhat brief and selective. For a +% thorough overview of graphics in LaTeX, see Goossens \emph{et +% al.}~\cite{Goossens2007}. +% +%\subsection{Macro-based methods} +% At the most basic, a chemical scheme is simply a collection of +% lines and symbols, as with any vector diagram. Hence, it is +% possible to construct schemes directly using packages such as +% PSTricks or |pgf|/|tikz|. This is a complex method, and cannot be +% recommended for anyone except the very experienced and brave. % -% Both |bpchem| and |chemcompounds| provide a variety of methods for -% defining chemical labels. In either case, the user should define -% the chemical label \emph{before} it is referenced by -% \cmd{\chemschemeref}. Errors are very likely to occur if this is -% not done. +% At a more practical level, there are two packages available which +% allow typesetting of chemical structures in (La)TeX, using +% specialised commands: XyMTeX and ppchTeX. Recent versions of the +% XyMTeX package have not been made available on \textsc{ctan}, and +% the version held there is therefore considered to be obsolete. On +% the other hand, the ppchTeX system, developed originally for +% ConTeXt, is available. Both systems suffer from the lack of +% chemical logic in the input: it is very hard to tell from the code +% what is being represented. Drawing items such as ``curly arrows'', +% or making subtle alterations to positioning, is very challenging in +% purely macro-based systems. For these reasons, it is usually much +% more sensible to examine the available graphical methods. % -% \section{Known issues} +%\subsection{Graphical methods} +% Moving to graphical systems, there is no reason that +% general-purpose vector drawing packages cannot be used for schemes. +% There are obviously several commercial (\textsc{CorelDraw}, +% \textsc{Adobe Illustrator}, \emph{etc.}) and freeware (for example +% the \textsc{gimp}) drawing packages that can be used in this way. +% Simply rings and lines can easily be constructed, although in +% general-purpose programs the user has to watch that all bonds +% are the same length. % -% The number replacement code relies on the use of |psfrag|, which -% can only be applied to \textsc{eps} graphics. Thus, users of -% pdfLaTeX will not benefit form the automated number replacement. -% For final compilation directly to \textsc{pdf}, it may be -% preferable to modify the graphics files and use |epstopdf| to -% include the files. The alternative is to use the more -% traditional route \textsc{dvi} $\to$ \textsc{ps} $\to$ -% \textsc{pdf}. +% For producing a large number of complex schemes, the particular +% abilities of dedicated software become a necessity. As well as the +% already-mentioned \textsc{ChemDraw}, programs such as \textsc{ISIS +% Draw} and \textsc{ChemSketch} are available free for personal +% use;\footnote{``Free'' as in without charge, not as in open +% source.} these programs are all Windows specific. In the +% open-source arena, there are a number of packages such as +% \textsc{XDrawChem} and \textsc{BKchem}, which offer cross-platform +% functionality. The differences between the various packages are in +% the ease of use, and ability to generate well-formattd output (for +% example, aligning structures). % -% Currently, the names of schemes are only available in English. If -% the correct translations are provided, the package author will -% aim to incorporate the appropriate code. +% One which deserves mention for the TeX user is TpX. This is a +% general purpose Windows graphics program specifically aimed at +% producing TeX-friendly output (such as PSTricks and |tikz| code) +% from a graphical interface. TpX can accept clipboard data from +% other programs, so can be used to produce EPS files from programs +% which do not have native export facilities (such as \textsc{ISIS +% Draw}). % -% \StopEventually{} +%\section{Known issues} +% +% The interaction of the different document classes, with options, +% plus the |babel| system means ensuring every possibility is covered +% is impossible. Users are asked to report any problems with +% compatibility with other packages or emulation of the standard +% float types. Additional |babel| stings are also welcome, as are +% improvements to those already provided. +% +% \StopEventually{\bibliographystyle{unsrt}\bibliography{chemscheme}} % % \iffalse %<*package> @@ -354,92 +603,174 @@ % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{chemscheme}% - [2007/08/05 v1.1 Support for chemical schemes] + [2007/10/04 v1.3 Support for chemical schemes] % \end{macrocode} +%\changes{v1.3}{2007/10/04}{Load \texttt{caption} for +% non-\texttt{memoir} classes} % The |psfrag| package is required to carry out the inclusion of -% chemical numbers in graphics. If the |memoir| package is not +% chemical numbers in graphics. Robust patching of commands is +% provided by |elatex|. If the |memoir| package is not % being used, the |float| package is used to provide support for -% new float types. However, if |memoir| is in use, |float| should -% not be loaded. +% new float types. However, if |memoir| is in use, |float| is not +% loaded. As |caption| makes things work very nicely too, we load +% that here if |memoir| is not in use. % \begin{macrocode} -\RequirePackage{psfrag} +\RequirePackage{psfrag,iflang} \@ifclassloaded{memoir}{} - {\RequirePackage{float}} + {\RequirePackage{float,caption}} +% \end{macrocode} +%\changes{v1.3}{2007/10/04}{Switch to using \texttt{chemcompounds} +% by default} +% Option processing now takes place. By default, |chemscheme| uses +% the |chemcompounds| package for managing chemical compound +% references. The options reflect this. +% \begin{macrocode} +\newif \ifchemsch@bpchem \chemsch@bpchemfalse +\DeclareOption{chemcompounds}{\chemsch@bpchemfalse} +\DeclareOption{bpchem}{\chemsch@bpchemtrue} % \end{macrocode} -% Option processing now takes place. This requires two Boolean -% values, which are declared here. By default, |chemscheme| uses -% |bpchem| for managing chemical compound references. The options -% reflect this. +% The |chapter| option is no longer used, so the user is told that it +% is ignored. Hopefully nothing bad happens, and so an error is not +% appropriate. % \begin{macrocode} -\newif \ifCHEMSCH@chapter \CHEMSCH@chapterfalse -\newif \ifCHEMSCH@bpchem \CHEMSCH@bpchemtrue -\DeclareOption{chapter}{\global\CHEMSCH@chaptertrue} -\DeclareOption{chemcompounds}{\global\CHEMSCH@bpchemfalse} -\DeclareOption{bpchem}{} +\DeclareOption{chapter}% + {\PackageInfo{chemscheme}% + {Ignoring obsolete option `chapter'}} \ProcessOptions % \end{macrocode} % -% \subsection{Support for schemes} -% -% \begin{macro}{\schemename} -% \begin{macro}{\listschemes} -% The new float type for schemes in produced using the |float| -% package, or the appropriate |memoir| code. First, names for -% schemes and the list of schemes are set up. These are provided -% for ease of modification, as demonstrated in the |memoir| manual. +%\subsection{Support for schemes} +%\begin{macro}{\schemename} +%\begin{macro}{\listschemename} +%\changes{v1.2}{2007/08/18}{Replaces \texttt{\textbackslash +% listschemes}} +% The default name for a scheme, and the default title for the list +% of schemes, are provided. Both command names follow the +% kernel conventions for figures and tables. % \begin{macrocode} \newcommand*{\schemename}{Scheme} -\newcommand*{\listschemes}{List of Schemes} +\newcommand*{\listschemename}{List of Schemes} % \end{macrocode} -% \end{macro} -% \end{macro} -% \begin{environment}{scheme} -% The \cmd{\newfloat} command is used to generate the new float type, -% first checking if numbering within chapters is requested. A -% suitable warning is issued if no chapters exist in the document. -% The syntax required depends on whether |float| or |memoir| is used -% for the definition. +%\end{macro} +%\end{macro} +%\begin{environment}{scheme} +% The \cmd{\newfloat} command is used to generate the new float type. +% The syntax depends on whether whether |float| or |memoir| is used +% for the definition. Notice that the formation of the new float has +% to wait for the beginning of the document, as this has to occur +% after |hyperref| may be loaded. +%\changes{v1.2}{2007/08/18}{Added \texttt{chapter} option to +% \texttt{memoir} \cs{newfloat} command} +%\changes{v1.2a}{2007/09/19}{Fixed error with \texttt{hyperref}} % \begin{macrocode} -\ifCHEMSCH@chapter - \ifx\chapter\@undefined - \PackageWarning{chemscheme}% - {No chapters in this document \MessageBreak% - Ignoring `chapter' option} - \@ifclassloaded{memoir} - {\newfloat{scheme}{los}{\schemename}} - {\newfloat{scheme}{tbp}{los}} - \else - \@ifclassloaded{memoir} - {\newfloat[chapter]{scheme}{los}{\schemename}} - {\newfloat{scheme}{tbp}{los}[chapter]} - \fi -\else - \@ifclassloaded{memoir} - {\newfloat{scheme}{los}{\schemename}} - {\newfloat{scheme}{tbp}{los}} -\fi +\@ifclassloaded{memoir}{% +% \end{macrocode} +% In the |memoir| case, floats are always defined numbered within +% chapters. +% \begin{macrocode} + \AtBeginDocument{% + \newfloat[chapter]{scheme}{los}{\schemename} % \end{macrocode} -% \end{environment} -% \begin{macro}{\listofschemes} -% To ensure that things are labelled correctly, the new float type -% is given an appropriate name. Notice that |memoir| does this at -% the float-definition stage. In common with the standard float -% types, a \cmd{\listof} command is provided for schemes. +% The |memoir| kernel makes various changes to the formatting of +% the default float types after they are declared. So the same is +% done here for schemes. The \cmd{\addtodef} macro is defined by +% |memoir|. Why all of this is done is not clear, but it is best +% to be on the safe side. +% \begin{macrocode} + \kill@lastcounter{losdepth} + \renewcommand*{\thescheme}{\thechapter.\@arabic\c@scheme} + \addtodef{\@smemfront}{}{\counterwithout{scheme}{chapter}} + \addtodef{\@smemmain}{}{% + \ifartopt\else + \counterwithin{scheme}{chapter} + \fi} + \addtodef{\backmatter}{}{% + \ifartopt\else + \counterwithout{scheme}{chapter}% + \setcounter{scheme}{0}% + \fi} + \ifartopt + \counterwithout{scheme}{chapter}% + \fi + } +}{% +% \end{macrocode} +%\changes{v1.3}{2007/10/04}{Fixed problem when \cs{chapter} +% expands to \cs{relax}} +% When using |float|, the standard LaTeX class behaviour is emulated. +% Only some classes define chapters, so this has to be tested and +% accounted for when forming the |scheme| float. +% \begin{macrocode} + \AtBeginDocument{% + \@ifundefined{chapter}{% + \newfloat{scheme}{tbp}{los}% + }{% + \newfloat{scheme}{tbp}{los}[chapter] +% \end{macrocode} +% In the standard classes which do define chapters, a bit of hacking +% occurs with the labelling of floats. So the same is done for +% schemes. \textsc{koma-script} doesn't do this, so a test is needed +% for that as well. +% \begin{macrocode} + \@ifundefined{KOMAScriptVersion}{% + \renewcommand*{\thescheme}% + {\ifnum\c@chapter>\z@ \thechapter.\fi \@arabic\c@scheme} + }{} +% \end{macrocode} +% To get the correct appearance for table of contents, the +% \cmd{\@chapter} macro is patched to recognise schemes. A bit of +% shuffling is required, since \cmd{\g@addto@macro} cannot be used +% here. +% \begin{macrocode} + \let\chemsch@orig@chapter\@chapter + \def\chemsch@chapter{% + \addtocontents{los}{\protect\addvspace{10\p@}}% + \chemsch@orig@chapter} + \let\@chapter\chemsch@chapter + } + } +} +% \end{macrocode} +%\end{environment} +%\begin{macro}{\listofschemes} +% To ensure that things are labelled correctly, the new float type is +% given an appropriate name. Notice that |memoir| does this at the +% float-definition stage. In common with the standard float types, a +% \cmd{\listof} command is provided for schemes. Notice again the +% need for almost everything to take place after any potential +% loading of |hyperref|. % \begin{macrocode} \@ifclassloaded{memoir} - {\newlistof{listofschemes}{los}{\listschemes}} + {\AtBeginDocument{% + \newlistof{listofschemes}{los}{\listschemename} +% \end{macrocode} +% Once again, various hacks are needed to get good emulation for +% |memoir|. +% \begin{macrocode} + \kill@lastcounter{losdepth} + \newlistentry[chapter]{scheme}{los}{0} + \cftsetindents{scheme}{0em}{2.3em} + \addtodef{\insertchapterspace}{}% + {\addtocontents{los}{\protect\addvspace{10pt}}} + \@ifundefined{c@losdepth}% + {\newcounter{losdepth}\setcounter{losdepth}{1}}{}% + } + } +% \end{macrocode} +% For the standard document classes, things are a bit less complex. +% Notice that \cmd{\floatname} is needed to define the name of a +% scheme as ``Scheme.'' +% \begin{macrocode} {\floatname{scheme}{\schemename} - \newcommand*{\listofschemes}[1][\listschemes]% - {\listof{scheme}{#1}}} + \newcommand*{\listofschemes}{\listof{scheme}{\listschemename}}} % \end{macrocode} % \end{macro} % -% \subsection{Positioning float contents} -% -% \begin{macro}{\floatcontentscentre} -% \begin{macro}{\floatcontentscenter} -% \begin{macro}{\floatcontentsleft} -% \begin{macro}{\floatcontentsright} +%\subsection{Positioning float contents} +%\begin{macro}{\floatcontentscentre} +%\begin{macro}{\floatcontentscenter} +%\begin{macro}{\floatcontentsleft} +%\begin{macro}{\floatcontentsright} % In order to centre the content of all floats, a method is needed % to break into the mechanism. None is provided by default, % but it can be achieved by patching \cmd{\@floatboxreset}. @@ -447,89 +778,238 @@ % off. % \begin{macrocode} \newcommand*{\floatcontentscentre}% - {\let\CHEMSCH@everyfloat\centering} + {\let\chemsch@everyfloat\centering} \let\floatcontentscenter\floatcontentscentre \newcommand*{\floatcontentsleft}% - {\let\CHEMSCH@everyfloat\relax} + {\let\chemsch@everyfloat\relax} \newcommand*{\floatcontentsright}% - {\let\CHEMSCH@everyfloat\raggedleft} -\let\CHEMSCH@floatboxreset\@floatboxreset + {\let\chemsch@everyfloat\raggedleft} +\let\chemsch@floatboxreset\@floatboxreset \floatcontentsleft -\def\@floatboxreset{\CHEMSCH@everyfloat\CHEMSCH@floatboxreset} +\def\@floatboxreset{\chemsch@everyfloat\chemsch@floatboxreset} % \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} % -% \subsection{Reference numbers in graphics} +%\subsection{\texttt{babel} support} +% To make the new float type work with |babel|, some alternative +% text is provided for non-English users. First, we need to know if +% |babel| is loaded \emph{before} |chemscheme| or after, as this +% affects one if the hacks needed for French. +% \begin{macrocode} +\newif \ifchemsch@babel \chemsch@babelfalse +\@ifpackageloaded{babel} + {\chemsch@babeltrue} + {} +% \end{macrocode} +% There is then one hack to be made for French which has to be made +% before the beginning of the document \emph{if} |babel| is loaded +% before |chemscheme|. This is only needed when |memoir| is not in +% use. So there is a run of tests to see if the conditions for the +% hack are met. |babel| support for French needs two name checks, +% \emph{zut alors}! +% \begin{macrocode} +\@ifclassloaded{memoir} + {} + {\@ifpackageloaded{babel} + {\IfLanguageName{french} + {\let\floatc@plain\FB@makecaption} + {\IfLanguageName{frenchb} + {\let\floatc@plain\FB@makecaption} + {}}} + {}} +% \end{macrocode} +% The definition of new stings is delayed until the beginning of the +% document, so that things work if |babel| is loaded after +% |chemscheme|. The multiple language names mean quite a bit of +% repetition here. +% \begin{macrocode} +\AtBeginDocument{% + \@ifpackageloaded{babel}{% + \addto{\captionsngerman}{\renewcommand*{\schemename}{Schema}} + \addto{\captionsngerman}% + {\renewcommand*{\listschemename}{Schemenverzeichnis}} + \addto{\captionsgerman}{\renewcommand*{\schemename}{Schema}} + \addto{\captionsgerman}% + {\renewcommand*{\listschemename}{Schemenverzeichnis}} +% \end{macrocode} +% French settings. |babel| also changes some style parameters here, +% so |chemscheme| tries to match this. +% \begin{macrocode} + \addto{\captionsfrench}% + {\renewcommand*{\schemename}{\scshape Sch\`eme}} + \addto{\captionsfrench}% + {\renewcommand*{\listschemename}{Table des sch\`emes}} + \addto{\captionsfrenchb}% + {\renewcommand*{\schemename}{\scshape Sch\`eme}} + \addto{\captionsfrenchb}% + {\renewcommand*{\listschemename}{Table des sch\`emes}} +% \end{macrocode} +% To make these changes, |babel| has to be instructed to reload the current +% language. +% \begin{macrocode} + \expandafter\selectlanguage\expandafter{\languagename} +% \end{macrocode} +% If |babel| was loaded after |chemscheme|, and the document is in +% French, then the non-|memoir| patch for floats is needed here. +% This is the same one described earlier, which cannot be delayed to +% here if |babel| is loaded first. +% \begin{macrocode} + \@ifclassloaded{memoir} + {} + {\IfLanguageName{french} + {\ifchemsch@babel\else + \let\floatc@plain\FB@makecaption + \fi} + {\IfLanguageName{frenchb} + {\ifchemsch@babel\else + \let\floatc@plain\FB@makecaption + \fi} + {}}} + {} + }{} +} +% \end{macrocode} % -% \begin{macro}{\chemschemerefmarker} -% \begin{macro}{\chemschemerefformat} -% The two macros \cmd{\chemschemerefmarker} and -% \cmd{\chemschemerefformat} are used to allow customisation of the -% behaviour of the package. Here defaults are provided. +%\subsection{Reference numbers in graphics} +%\begin{macro}{\schemerefmarker} +%\changes{v1.3}{2007/10/04}{Name change} +%\begin{macro}{\schemerefformat} +%\changes{v1.3}{2007/10/04}{Name change} +% The two macros \cmd{\schemerefmarker} and \cmd{\schemerefformat} +% are used to allow customisation of the behaviour of the package. +% Here defaults are provided. % \begin{macrocode} -\newcommand{\chemschemerefmarker}{TMP} -\newcommand{\chemschemerefformat}{\textsf} +\newcommand*{\schemerefmarker}{TMP} +\newcommand*{\schemerefformat}{\textsf} % \end{macrocode} -% \end{macro} -% \end{macro} -% \begin{macro}{\CHEMSCH@label} +%\end{macro} +%\end{macro} +%\begin{macro}{\chemsch@label} % Depending on the user options provided, either |bpchem| or -% |chemcompounds| is loaded to manage chemical citations. The -% macro \cmd{\CHEMSCH@label} is defined as the labelling command of -% the appropriate package. +% |chemcompounds| is loaded to manage chemical citations. The macro +% \cmd{\chemsch@label} is defined as the labelling command of the +% appropriate package. % \begin{macrocode} -\ifCHEMSCH@bpchem +\ifchemsch@bpchem \RequirePackage{bpchem} - \let\CHEMSCH@label\CNlabel + \let\chemsch@label\CNlabel \else \RequirePackage{chemcompounds} - \let\CHEMSCH@label\compound + \let\chemsch@label\compound \fi % \end{macrocode} -% \end{macro} -% \begin{macro}{\chemschemeref} -% The referencing macro is a wrapper for the appropriate -% \cmd{\psfrag} command. The first argument of \cmd{\chemschemeref} -% is the temporary code assigned to a compound, with the second -% containing the reference used for the compound in the citation -% scheme. The use of |[b][b]| places the new label at the centre of -% the position of the temporary one, at the same vertical position. +%\end{macro} +%\begin{macro}{\chemsch@num} +% A counter is needed for automatic substitution of reference +% numbers. This has to be a TeX count, rather than a LaTeX counter, +% as it has to be local. % \begin{macrocode} -\newcommand{\chemschemeref}[2]{% - \psfrag{\chemschemerefmarker#1}[b][b]% - {\chemschemerefformat{\CHEMSCH@label{#2}}}% +\newcount\chemsch@num +% \end{macrocode} +%\end{macro} +%\begin{macro}{\schemeref} +%\changes{v1.3}{2007/10/04}{New macro} +% The user macro for referencing a compound in a graphic. First the +% automatic counter is incremented. +% \begin{macrocode} +\newcommand*{\schemeref}{% + \advance\chemsch@num\@ne% +% \end{macrocode} +% Now the presence of an optional argument is tested for. If there +% is not one, the value of the automatic counter is used. +% \begin{macrocode} + \@ifnextchar[% + {\chemsch@schemeref} + {\chemsch@schemeref[\schemerefmarker\the\chemsch@num]} } % \end{macrocode} -% \end{macro} -% \begin{macro}{\chemschemerefsub} -% The |sub| version of the referencing command is needed as |bpchem| -% allows tracking of sub-compounds (\emph{e.g.}~\textbf{1a}, -% \textbf{1b}, \emph{etc.}). As |chemcompounds| does not do this, -% the command in that case gobbles up the third argument and gives -% the user a suitable warning. +%\end{macro} +%\begin{macro}{\chemsch@schemeref} +% The internal command to substitute the temporary marker by +% the automatic label text. The use of |[b][b]| ensures that +% the new text is centred on the position of the marker. +% \begin{macrocode} +\def\chemsch@schemeref[#1]#2{% + \wlog{Replaing #1 by #2}% + \psfrag{#1}[b][b]% + {\schemerefformat{\chemsch@label{#2}}}% +} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\chemsch@schemerefsub} +% For sub-referencing using |bpchem|, a similar macro is needed using +% the \cmd{\CNlabelsub} command. This is defined here, with the user +% macro later. +% \begin{macrocode} +\def\chemsch@schemerefsub[#1]#2#3{% + \psfrag{#1}[b][b]% + {\schemerefformat{\CNlabelsub{#2}{#3}}}% +} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\chemschemeref} +%\changes{v1.3}{2007/10/04}{Converted to a wrapper for +% \cs{schemeref}} +% The \cmd{\chemschemeref} is now a backward-compatibility wrapper +% for \cmd{\schemeref}. +% \begin{macrocode} +\newcommand*{\chemschemeref}[1]{% + \schemeref[#1]% +} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\schemerefsub} +%\changes{v1.3}{2007/10/04}{New macro} +%\begin{macro}{\chemschemerefsub} +%\changes{v1.3}{2007/10/04}{Now a wrapper for \cs{schemerefsub}} +% The user sub-referencing macro is defined in a package-dependent +% manner. If |bpchem| is loaded, then \cmd{\schemerefsub} works in +% the same way as \cmd{\schemeref}, but calling the |sub| version of +% the internal macro. % \begin{macrocode} -\ifCHEMSCH@bpchem - \newcommand{\chemschemerefsub}[3]{% - \psfrag{\chemschemerefmarker#1}[b][b]% - {\chemschemerefformat{\CNlabelsub{#2}{#3}}}% +\ifchemsch@bpchem + \newcommand*{\schemerefsub}{% + \advance\chemsch@num\@ne% + \@ifnextchar[% + {\chemsch@schemerefsub} + {\chemsch@schemerefsub[\schemerefmarker\the\chemsch@num]} } +% \end{macrocode} +% Once again, backward compatibility is maintained. +% \begin{macrocode} + \newcommand*{\chemschemerefsub}[1]{% + \schemerefsub[#1]% + } +% \end{macrocode} +% If |chemcompounds| is in use, then the sub-reference commands +% gobble the arguments given. The automatic counter is still +% incremented, so that things stay (reasonably) logical. +% \begin{macrocode} \else - \newcommand{\chemschemerefsub}[3]{% + \newcommand*{\schemerefsub}[3][]{% + \advance\chemsch@num\@ne% \PackageWarning{chemscheme}% {`chemcompound' option active\MessageBreak Command \protect\chemschemerefsub\space not used \MessageBreak Please alter your source to \MessageBreak \protect\chemschemeref}} + \newcommand*{\chemschemerefsub}[1]{\schemerefsub}% \fi % \end{macrocode} -% \end{macro} +%\end{macro} +%\end{macro} % \iffalse %</package> % \fi -% \iffalse +% \PrintChanges +% \PrintIndex +% \Finale +%\iffalse +% From here on, the |.dtx| contains support files for the +% documentation. %<*scheme> %!PS-Adobe-2.0 EPSF-1.2 %%Creator: ChemDraw Std(tm) 10.0 @@ -1198,7 +1678,148 @@ gr end %%Trailer showpage %</scheme> -% \fi -% \PrintChanges -% \PrintIndex -% \Finale +%<*bib> +@book{Goossens2007, + author = {Michel Goossens and Frank Mittelbach and Sebastian Rahtz and Denis Roegel}, + title = {The LaTeX Graphics Companion}, + subtitle = {Illustrating Documents with TeX and Postscript}, + publisher = {Addison Wesley}, + year = {2007}, + series = {Tools and Techniques for Computer Typesetting}, + edition = {2}, +} +%</bib> +%<*jawltxdoc> +% The following is convenient method for collecting together package +% loading, formatting commands and new macros used to format |dtx| +% files written by the current author. It is based on the similar +% files provided by Will Robertson in his packages and Heiko Oberdiek +% as a stand-alone package. Notice that it is not intended for other +% users: there is no error checking! However, it is covered by the +% LPPL in the same way as the rest of this package. +% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{jawltxdoc} + [2007/10/04 v1.0a] +% First of all, a number of support packages are loaded. +\usepackage[T1]{fontenc} +\usepackage[english,UKenglish]{babel} +\usepackage[scaled=0.95]{helvet} +\usepackage[version=3]{mhchem} +\usepackage[final]{microtype} +\usepackage{mathpazo,booktabs,array,url,graphicx,courier,unitsdef} +\usepackage{upgreek,ifpdf,listings} +% If using PDFLaTeX, the source will be attached to the PDF. This +% is basically the system used by Heiko Oberdiek, but with a check +% that PDF mode is enabled. +\ifpdf + \usepackage{embedfile} + \embedfile[% + stringmethod=escape,% + mimetype=plain/text,% + desc={LaTeX docstrip source archive for package `\jobname'}% + ]{\jobname.dtx} +\fi +\usepackage{\jobname} +\usepackage[numbered]{hypdoc} +% +% To typeset examples, a new environment is needed. The code below +% is based on that in used by |listings|, but is modified to get +% better formatting for this context. The formatting of the output +% is basically that in Will Robertson's |dtx-style| file. +\newlength\LaTeXwidth +\newlength\LaTeXoutdent +\newlength\LaTeXgap +\setlength\LaTeXgap{1em} +\setlength\LaTeXoutdent{-0.15\textwidth} +\def\typesetexampleandcode{% + \begin{list}{}{% + \setlength\itemindent{0pt} + \setlength\leftmargin\LaTeXoutdent + \setlength\rightmargin{0pt} + } + \item + \setlength\LaTeXoutdent{-0.15\textwidth} + \begin{minipage}[c]{\textwidth-\LaTeXwidth-\LaTeXoutdent-\LaTeXgap} + \lst@sampleInput + \end{minipage}% + \hfill% + \begin{minipage}[c]{\LaTeXwidth}% + \hbox to\linewidth{\box\lst@samplebox\hss}% + \end{minipage}% + \end{list} +} +\def\typesetcodeandexample{% + \begin{list}{}{% + \setlength\itemindent{0pt} + \setlength\leftmargin{0pt} + \setlength\rightmargin{0pt} + } + \item + \begin{minipage}[c]{\LaTeXwidth}% + \hbox to\linewidth{\box\lst@samplebox\hss}% + \end{minipage}% + \lst@sampleInput + \end{list} +} +\def\typesetfloatexample{% + \begin{list}{}{% + \setlength\itemindent{0pt} + \setlength\leftmargin{0pt} + \setlength\rightmargin{0pt} + } + \item + \lst@sampleInput + \begin{minipage}[c]{\LaTeXwidth}% + \hbox to\linewidth{\box\lst@samplebox\hss}% + \end{minipage}% + \end{list} +} +\def\typesetcodeonly{% + \begin{list}{}{% + \setlength\itemindent{0pt} + \setlength\leftmargin{0pt} + \setlength\rightmargin{0pt} + } + \item + \begin{minipage}[c]{\LaTeXwidth}% + \hbox to\linewidth{\box\lst@samplebox\hss}% + \end{minipage}% + \end{list} +} +\edef\LaTeXexamplefile{\jobname.tmp} +\lst@RequireAspects{writefile} +\newbox\lst@samplebox +\lstnewenvironment{LaTeXexample}[1][\typesetexampleandcode]{% + \let\typesetexample#1 + \global\let\lst@intname\@empty + \setbox\lst@samplebox=\hbox\bgroup + \setkeys{lst}{language=[LaTeX]{TeX},tabsize=4,gobble=2,% + breakindent=0pt,basicstyle=\small\ttfamily,basewidth=0.51em,% + keywordstyle=\color{blue},% +% Notice that new keywords should be added here. The list is simply +% macro names needed to typeset documentation of the package +% author. + morekeywords={bibnote,citenote,bibnotetext,bibnotemark,% + thebibnote,bibnotename,includegraphics,schemeref,% + floatcontentsleft,floatcontentsright,floatcontentscentre,% + schemerefmarker,compound,schemerefformat,color,% + startchemical,stopchemical,chemical,setupchemical,bottext,% + listofschemes}} + \lst@BeginAlsoWriteFile{\LaTeXexamplefile} +}{% + \lst@EndWriteFile\egroup + \setlength\LaTeXwidth{\wd\lst@samplebox} + \typesetexample% +} +\def\lst@sampleInput{% + \MakePercentComment\catcode`\^^M=10\relax + \small% + {\setkeys{lst}{SelectCharTable=\lst@ReplaceInput{\^\^I}% + {\lst@ProcessTabulator}}% + \leavevmode \input{\LaTeXexamplefile}}% + \MakePercentIgnore% +} +\hyphenation{PDF-LaTeX} +%</jawltxdoc> +%\fi |