Pregunta

Sphinx para generar la salida del látex que se convirtió en un PDF para la salida en forma de libro usando pdftex .

Actualmente, tengo avisos, advertencias y otras "advertencias" que muestra el interior de una caja acotada, en un estilo que se ve un poco como esto:

-----------------------------------
| Warning:     lorem ipsum foozle |
|  fuzzle fuzz buzz               |
|----------------------------------

El látex que genera este tipo de miradas una caja como esta:

\begin{notice}{warning}{Warning:}
The \code{repoze.bfg} documentation is offered under the
Creative Commons Attribution-Nonconmmercial-Share Alike 3.0 United
States License.
\end{notice}

Hay una serie de comandos en un archivo LaTeX .sty que proporcionan el cuadro comportamiento:

% Notices / Admonitions
%
\newlength{\py@noticelength}

\newcommand{\py@heavybox}{
\setlength{\fboxrule}{1pt}
\setlength{\fboxsep}{7pt}
\setlength{\py@noticelength}{\linewidth}
\addtolength{\py@noticelength}{-2\fboxsep}
\addtolength{\py@noticelength}{-2\fboxrule}
\setlength{\shadowsize}{3pt}
\Sbox
\minipage{\py@noticelength}
}
\newcommand{\py@endheavybox}{
\endminipage
\endSbox
\fbox{\TheSbox}
}

% Some are quite plain:
\newcommand{\py@noticestart@note}{}
\newcommand{\py@noticeend@note}{}
\newcommand{\py@noticestart@hint}{}
\newcommand{\py@noticeend@hint}{}
\newcommand{\py@noticestart@important}{}
\newcommand{\py@noticeend@important}{}
\newcommand{\py@noticestart@tip}{}
\newcommand{\py@noticeend@tip}{}

% Others gets more visible distinction:
\newcommand{\py@noticestart@warning}{\py@heavybox}
\newcommand{\py@noticeend@warning}{\py@endheavybox}
\newcommand{\py@noticestart@caution}{\py@heavybox}
\newcommand{\py@noticeend@caution}{\py@endheavybox}
\newcommand{\py@noticestart@attention}{\py@heavybox}
\newcommand{\py@noticeend@attention}{\py@endheavybox}
\newcommand{\py@noticestart@danger}{\py@heavybox}
\newcommand{\py@noticeend@danger}{\py@endheavybox}
\newcommand{\py@noticestart@error}{\py@heavybox}
\newcommand{\py@noticeend@error}{\py@endheavybox}

\newenvironment{notice}[2]{
  \def\py@noticetype{#1}
  \csname py@noticestart@#1\endcsname
  \par\strong{#2}
}{\csname py@noticeend@\py@noticetype\endcsname}

En lugar de simplemente tener un cuadro alrededor de la notificación y tener una palabra representa el tipo de notificación dentro de la caja, me gustaría conservar el cuadro alrededor de la admonitition, pero sustituir la palabra "advertencia" en el cuadro con una imagen , así:

-------------------------------------------
|    ---                                  |
|   /   \                                 |
|   \   /                                 |
|    ---    Fuzzle foo buz lorem ipsum    |
-------------------------------------------

No se puede cambiar el \ begin {aviso} ... \ end {} Aviso literales de látex prestados por Sphinx (bueno, yo puedo, pero es un verdadero dolor en el culo). Yo prefiero sólo hay que poner la lógica en una nueva newenvironment {aviso} macro \. ¿Alguien puede recomendar una estrategia? Todo lo que he probado hasta ahora ha terminado en lágrimas.

¿Fue útil?

Solución

Trate lo siguiente (lo que requiere el paquete ifthen o xifthen para el comando \ifthenelse):

% Keep a copy of the original notice environment
\let\origbeginnotice\notice
\let\origendnotice\endnotice

% Redefine the notice environment so we can add our own code to it
\renewenvironment{notice}[2]{%
  \origbeginnotice{#1}{#2}% equivalent to original \begin{notice}{#1}{#2}
  % load graphics
  \ifthenelse{\equal{#1}{warning}}{\includegraphics{warning}}{}
  \ifthenelse{\equal{#1}{notice}}{\includegraphics{notice}}{}
  % etc.
}{%
  \origendnotice% equivalent to original \end{notice}
}

Vas a tener que encontrar una manera de conseguir este código en el preámbulo del documento.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top