![如何暂时删除定义环境中的格式?](https://linux22.com/image/242788/%E5%A6%82%E4%BD%95%E6%9A%82%E6%97%B6%E5%88%A0%E9%99%A4%E5%AE%9A%E4%B9%89%E7%8E%AF%E5%A2%83%E4%B8%AD%E7%9A%84%E6%A0%BC%E5%BC%8F%EF%BC%9F.png)
我有一个定义,写如下:
\begin{definition}
This is a definition, in which I would like to have a few normal words.
\end{definition}
通常,整个定义都以斜体。但我想删除“正常”格式,使其看起来没有斜体。有没有什么快捷的方法可以实现这个目的?
答案1
您可以使用 手动更改字体形状\upshape
。或者,您可以重新定义\itshape
(切换到斜体字体)意味着将其默认为\upshape
。后者可以使用 [etoolbox
软件包 ][etoolbox-pkg] 提供的补丁来实现。但是,即使更改仅限于环境,其他\itshape
用途也会对 进行更改\upshape
。在这种情况下,也许这不是问题。
\documentclass{article}
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\newenvironment{definition}%
{\itshape}% \begin{definition}
{}% \end{definition}
\begin{document}
% Normal definition
\begin{definition}
This is a definition, in which I would like to have a few normal words.
\end{definition}
% Manually corrected definition
\begin{definition}
\upshape This is a definition, in which I would like to have a few normal words.
\end{definition}
\AtBeginEnvironment{definition}{\renewcommand{\itshape}{\upshape}}% You can also place this in your document preamble
% Automatically corrected definition
\begin{definition}
This is a definition, in which I would like to have a few normal words.
\end{definition}
\end{document}