Images in warnings / warnings / notifications

I am currently using Sphinx to generate LaTeX output, which turns into PDF for book style output using pdftex.

I currently have notifications, warnings, and other β€œwarnings” appearing inside a limited style window that looks something like this:

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

LaTeX creating such a field looks like this:

 \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} 

The LaTeX.sty file has a series of commands that provide window behavior:

 % 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} 

Instead of having a box around the notification and having a word representing the type of notification inside the box, I would like to keep the box around the ad, but replace the word β€œwarning” in the box with an image, like this:

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

I can't change the latex literals \ begin {notice} ... \ end {notice} provided by Sphinx (well, I can, but it's a real pain in the ass). I would rather just put the logic in the new \ newenvironment {notice} macro. Can anyone recommend a strategy? Everything I've tried so far has ended in tears.

+4
source share
1 answer

Try the following (the ifthen or xifthen package is required for the \ifthenelse xifthen ):

 % 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} } 

You need to find a way to get this code in the preamble of the document.

+5
source

All Articles