我目前使用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} 宏中。谁能推荐一个策略?到目前为止,我所做的一切都以眼泪告终。