Re: Admonitions and Latex

Guenter Milde via Docutils-develop <[email protected]>
Newsgroups gmane.text.docutils.devel
Message-ID <[email protected]>
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



_______________________________________________
Docutils-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-develop

Please use "Reply All" to reply to the list.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.