Discussion:
[Docutils-users] Custom admonitions in rst2latex
Sébastien Dailly
2017-04-28 07:29:55 UTC
Permalink
Hello,

I want to configure a user defined admonition with rst2latex.
.. admonition:: test
This is a test
\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
\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 ?

[1] http://docutils.sourceforge.net/docs/user/latex.html#admonitions

Thanks a lot !
--
Sébastien
Guenter Milde
2017-04-28 17:07:31 UTC
Permalink
Post by Sébastien Dailly
Hello,
I want to configure a user defined admonition with rst2latex.
.. admonition:: test
This is a test
\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
\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).


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to r
Dailly Sébastien
2017-04-30 08:34:54 UTC
Permalink
Post by Guenter Milde
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
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
environments.
The above example should be
\expandafter\newcommand\csname DUadmonitionadmonition-test\endcsname{…}
or alternatively
\makeatletter
\makeatother
(in a package file (*.sty) you can omit the \makeat... lines).
Hope this helps,
Thanks a lot, the solution you give are much better than the *sed
command* I've use.

This would be very helpfull to add those exemple on the page «
Generating LaTeX with Docutils ».

Regard,
--
Sébastien
Guenter Milde
2017-05-01 17:28:22 UTC
Permalink
On 2017-04-30, Dailly Sébastien wrote:

...
Post by Dailly Sébastien
This would be very helpfull to add those exemple on the page «
Generating LaTeX with Docutils ».
Examples are added to the SVN repo version (latex.txt) and will be public
with the next website update.

You may download a snapshot (see http://docutils.sourceforge.net/) and
compile the newest docs for local use.

Günter


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.

Loading...