5

私は現在、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}マクロに配置したいと思います。誰かが戦略を推薦できますか?私がこれまでに試したことはすべて涙で終わった。

4

1 に答える 1

5

次のことを試してください(コマンドにifthenまたはxifthenパッケージが必要です)。\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}
}

このコードをドキュメントの前文に組み込む方法を見つける必要があります。

于 2010-01-03T06:14:14.547 に答える