告诫/警告/通知中的图片
我目前使用 Sphinx 生成 LaTeX 输出,然后使用 pdftex 将其转换为 PDF 以进行书籍样式输出。
目前,我有通知、警告和其他“警告”显示在一个有界框中,其样式看起来有点像这样:
-----------------------------------
| Warning: lorem ipsum foozle |
| fuzzle fuzz buzz |
|----------------------------------
生成这样一个框的 LaTeX 看起来像这样:
\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}
LaTeX 中有一系列命令提供该框的 .sty 文件 行为:
% 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}
我不想只在通知周围有一个框并在框内有一个代表通知类型的单词,我想保留警告周围的框,但用图像替换框中的“警告”一词,像这样:
-------------------------------------------
| --- |
| / \ |
| \ / |
| --- Fuzzle foo buz lorem ipsum |
-------------------------------------------
我无法更改 Sphinx 渲染的 \begin{notice} ... \end{notice} 乳胶文字(好吧,我可以,但这真的很痛苦)。我宁愿将逻辑放在新的 \newenvironment{notice} 宏中。有人可以推荐一个策略吗?到目前为止我所尝试的一切都以泪水告终。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试以下操作(这需要
\ifthenelse
命令的ifthen
或xifthen
包):您必须找到一种方法来获取此内容代码放入文档的序言中。
Try the following (which requires the
ifthen
orxifthen
package for the\ifthenelse
command):You'll have to find a way to get this code into the preamble of the document.