Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 524983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:37:28+00:00 2026-05-13T08:37:28+00:00

I currently use Sphinx to generate LaTeX output which is turned into a PDF

  • 0

I currently use Sphinx to generate LaTeX output which is turned into a PDF for book-style output using pdftex.

Currently, I have notices, warnings, and other “admonitions” showing up inside a bounded box, in a style that looks a little like this:

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

The LaTeX that generates such a box 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}

There are a series of commands in a LaTeX .sty file that provide the box
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 just having a box around the notice and having a word represent the type of notice inside the box, I’d like to retain the box around the admonitition, but replace the word “warning” in the box with an image, like so:

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

I cannot change the \begin{notice} … \end{notice} latex literals rendered by Sphinx (well, I can, but it’s a real pain in the ass). I’d prefer to just put the logic in a new \newenvironment{notice} macro. Can anyone recommend a strategy? Everything I’ve tried so far has ended in tears.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:37:28+00:00Added an answer on May 13, 2026 at 8:37 am

    Try the following (which requires the ifthen or xifthen package for the \ifthenelse command):

    % 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’ll have to find a way to get this code into the preamble of the document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently use the following expression which I use to put paragraph tags around
We currently use MOSS 2007 for our company intranet site and we are looking
I currently use PluralSight for online video training on .net related technologies. Their videos
I currently use CKEditor on my website, however not every time users access the
I currently use nginx with passenger to serve my rails app. considering including a
I currently use the Android Monkey tool for stress testing Android system/packages. I find
I currently use MyIasm as my default engine, i ran mysqltuner to check some
I currently use a the databse to store my messages but I guess there
I need to migrate a website to a new CMS. We do not have
There has been a post about setting cron job to index: Use a Cron

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.