首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >警告/警告/通知中的图像

警告/警告/通知中的图像
EN

Stack Overflow用户
提问于 2010-01-03 09:21:50
回答 1查看 914关注 0票数 5

我目前使用Sphinx生成LaTeX输出,然后使用pdftex将其转换为书籍样式的输出。

目前,我在一个有边界的框中显示了通知、警告和其他“警告”,样式看起来有点像这样:

代码语言:javascript
复制
-----------------------------------
| Warning:     lorem ipsum foozle |
|  fuzzle fuzz buzz               |
|----------------------------------

生成这样一个框的LaTeX如下所示:

代码语言:javascript
复制
\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文件中有一系列命令可提供框行为:

代码语言:javascript
复制
% 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}

我希望保留警告框周围的框,而不是只在通知周围有一个框,并在框中用一个单词表示通知的类型,而是用图像替换框中的“警告”一词,如下所示:

代码语言:javascript
复制
-------------------------------------------
|    ---                                  |
|   /   \                                 |
|   \   /                                 |
|    ---    Fuzzle foo buz lorem ipsum    |
-------------------------------------------

我不能更改由Sphinx呈现的\begin{notice} ... \end{notice} latex文字(嗯,我可以,但这是一个真正的麻烦)。我更喜欢将逻辑放在一个新的\newenvironment{notice}宏中。有谁能推荐一个策略吗?到目前为止,我所尝试的一切都以泪水告终。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-01-03 14:14:15

尝试执行以下操作(这需要\ifthenelse命令的ifthenxifthen包):

代码语言:javascript
复制
% 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}
}

您必须找到一种方法将此代码放入文档的前言中。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1993578

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档