From: Guenter M. <mi...@us...> - 2017-04-28 17:07:51
|
On 2017-04-28, Sébastien Dailly wrote: > Hello, > I want to configure a user defined admonition with rst2latex. > Suppose I have this block in the rst document : >> .. admonition:: test >> This is a test > rst2latex transform this text into : >> \DUadmonition[admonition-test]{ >> \DUtitle[admonition-test]{test} >> This is a test >> } > Now I want to apply a custom style to this block, as described in « > Generating latex with docutils » [1], but I cannot create a command > named : >> \newcommand{\DUadmonitionadmonition-test}[1]{…}} > Latex does not allow to create a command with a « - » > You told me that the latex writer as been rewritten in the last > docutils version. Is the problem still present ? Yes, this problem is still present: The doctree for the above example is <admonition classes="admonition-test"> <title> test <paragraph> This is a test i.e. it is an example of class arguments that cannot be part of a standard latex command name mentioned in "latex.txt": Class arguments may contain numbers and hyphens, which need special treatment in LaTeX command names (see `class directive`_). The commands ``\csname`` and ``\endcsname`` or the special command ``\@namedef`` can help with the definition of corresponding macros or environments. The above example should be \expandafter\newcommand\csname DUadmonitionadmonition-test\endcsname{…} or alternatively \makeatletter \@namedef{DUadmonitionadmonition-test}{…} \makeatother (in a package file (*.sty) you can omit the \makeat... lines). Hope this helps, Günter PS: I found a typo in the latex writer documentation: \begincsname should be replaced by \csname (done in the repo). |