2010-01-03 151 views
4

我目前使用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} 

有膠乳.sty文件提供盒 行爲的一系列命令:

% Notices/Admonitions 
% 
\newlength{\[email protected]} 

\newcommand{\[email protected]}{ 
\setlength{\fboxrule}{1pt} 
\setlength{\fboxsep}{7pt} 
\setlength{\[email protected]}{\linewidth} 
\addtolength{\[email protected]}{-2\fboxsep} 
\addtolength{\[email protected]}{-2\fboxrule} 
\setlength{\shadowsize}{3pt} 
\Sbox 
\minipage{\[email protected]} 
} 
\newcommand{\[email protected]}{ 
\endminipage 
\endSbox 
\fbox{\TheSbox} 
} 

% Some are quite plain: 
\newcommand{\[email protected]@note}{} 
\newcommand{\[email protected]@note}{} 
\newcommand{\[email protected]@hint}{} 
\newcommand{\[email protected]@hint}{} 
\newcommand{\[email protected]@important}{} 
\newcommand{\[email protected]@important}{} 
\newcommand{\[email protected]@tip}{} 
\newcommand{\[email protected]@tip}{} 

% Others gets more visible distinction: 
\newcommand{\[email protected]@warning}{\[email protected]} 
\newcommand{\[email protected]@warning}{\[email protected]} 
\newcommand{\[email protected]@caution}{\[email protected]} 
\newcommand{\[email protected]@caution}{\[email protected]} 
\newcommand{\[email protected]@attention}{\[email protected]} 
\newcommand{\[email protected]@attention}{\[email protected]} 
\newcommand{\[email protected]@danger}{\[email protected]} 
\newcommand{\[email protected]@danger}{\[email protected]} 
\newcommand{\[email protected]@error}{\[email protected]} 
\newcommand{\[email protected]@error}{\[email protected]} 

\newenvironment{notice}[2]{ 
    \def\[email protected]{#1} 
    \csname [email protected]@#1\endcsname 
    \par\strong{#2} 
}{\csname [email protected]@\[email protected]\endcsname} 

除了在通知旁邊放一個方框,並且用一個詞代表箱子內部的通知類型,我希望保留箱子周圍的箱子,但是用圖像替換箱子中的「警告」一詞,像這樣:

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

我不能改變的\開始{}通知... \由獅身人面像渲染結束{}通知乳膠文字(好吧,我可以,但它是在屁股真正的痛苦)。我寧願將邏輯放在新的\ newenvironment {notice}宏中。誰能推薦一個策略?我迄今爲止所嘗試過的所有東西都以眼淚結束。

回答

5

請嘗試以下(這需要ifthenxifthen包爲\ifthenelse命令):

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

你必須找到一種方式來獲得此代碼插入到文檔的序言。