From: Guenter M. <mi...@us...> - 2023-11-25 22:26:08
|
Dear Jérôme, On 2023-11-24, Jérôme Carretero wrote: > From an admonition title mytitle and class myclass and body text, the > latex generator generates: > \begin{DUclass}{myclass} > \begin{DUadmonition} > \DUtitle{mytitle} > text > \end{DUadmonition} > \end{DUclass} ... > In order to transform this ... > I've had to do: ... > Which I find a bit dirty. > Is there a better solution? With:: .. admonition:: mytitle :class: rappel body text I can get a custom title with the LaTeX preamble:: \newcommand*{\DUCLASSrappel}{ \renewcommand*{\DUtitle}[1]{\emph{Rappel: ##1}} } * The re-definition is local to the environment, so you don't need to save/restore the original function. * In the nested function redefinition, the argument placeholder requires two hashes, ``#1`` → ``##1``! This is described in https://docutils.sourceforge.io/docs/user/latex.html#titles Attention: typos. I just added a missing ``}`` and the second ``#`` in the document source. > I seem to recall that before, the admonition title was included as an > argument to DUadmonition, and it was easier to process. Yes, this change is described in https://docutils.sourceforge.io/RELEASE-NOTES.html#release-0-18-2021-10-26 legacy_class_functions setting default changed to "False", admonitions are now environments. So, the quick and dirty fix is ``rst2latex --legacy-class-functions``. Hope this helps, Günter |