gpt4 book ai didi

latex - 如何在不干扰其他环境的情况下自定义现有的LaTeX环境

转载 作者:行者123 更新时间:2023-12-01 10:21:39 35 4
gpt4 key购买 nike

我正在使用Sphinx记录项目。它从restructured text生成LaTeX文件。

我想为提示和注释设置灰色背景色,因此在创建了灰盒环境后,我自定义了通知环境:

\definecolor{MyGray}{rgb}{0.80,0.80,0.80}

\makeatletter\newenvironment{graybox}{%
\begin{lrbox}{\@tempboxa}\begin{minipage}{\columnwidth}}{\end{minipage}\end{lrbox}%
\colorbox{MyGray}{\usebox{\@tempboxa}}
}\makeatother

\makeatletter
\renewenvironment{notice}[2]{
\begin{graybox}
\bf\it
\def\py@noticetype{#1}
\par\strong{#2}
\csname py@noticestart@#1\endcsname
}
{
\csname py@noticeend@\py@noticetype\endcsname
\end{graybox}
}
\makeatother

除非我将 figure环境放置在notice环境中,否则一切正常。在这种情况下,我会收到此错误:

LaTeX错误:不在外部par模式下

有没有办法为该通知环境设置灰色背景?

最佳答案

这是一个FAQ。将图形(或任何其他可以在输出中移动到其他位置的“浮点数”)放在灰色框中是没有意义的;如果您希望图形包含一个灰色框,请将灰色框环境放在图形环境中。

关于latex - 如何在不干扰其他环境的情况下自定义现有的LaTeX环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/606746/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com