我目前使用Sphinx生成LaTeX输出,然后使用pdftex将其转换为书籍样式的输出。
目前,我在一个有边界的框中显示了通知、警告和其他“警告”,样式看起来有点像这样:
-----------------------------------
| 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} latex文字(嗯,我可以,但这是一个真正的麻烦)。我更喜欢将逻辑放在一个新的\newenvironment{notice}宏中。有谁能推荐一个策略吗?到目前为止,我所尝试的一切都以泪水告终。
发布于 2010-01-03 14:14:15
尝试执行以下操作(这需要\ifthenelse命令的ifthen或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}
}您必须找到一种方法将此代码放入文档的前言中。
https://stackoverflow.com/questions/1993578
复制相似问题