2010-01-03 1 views
4

현재 Sphinx을 사용하여 pdftex를 사용하여 책 스타일 출력을 위해 PDF로 변환 된 LaTeX 출력을 생성합니다.경고/경고의 이미지

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

같은 상자를 생성하는 라텍스 다음과 같습니다

현재,이 같은 조금 보이는 스타일로, 한정된 상자 안에 게재 사항, 경고 및 기타 "훈계"가 이 :

\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} 
,745는

알림 주위에 상자가 있고 단어가 상자 안에있는 알림 유형을 나타내는 대신, 경고 주위에 상자를 유지하고 이미지의 상자에 "경고"단어를 바꿉니다. 그래서 같은 :

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

나는 변경할 수 없습니다 \ 시작 {공지} ... \ 스핑크스에 의해 렌더링 끝 {공지} 라텍스 리터럴 (물론, 내가 할 수있는,하지만 엉덩이에 진짜 고통이다). 새로운 \ newenvironment {notice} 매크로에 로직을 넣는 것을 선호합니다. 누구든지 전략을 추천 할 수 있습니까? 지금까지 시도한 모든 것은 눈물로 끝났습니다.

답변

5

는합니다 (\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} 
} 

당신은 문서의 서문에이 코드를 얻을 수있는 방법을 찾아야 할 것이다.