对于一本书,我想将示例环境中的默认字体(以与定理相同的方式声明)更改为通常的罗马字体(不是斜体),以便不会出现大面积的斜体字体。我该如何做到这一点而不会在其他地方引起复杂情况?可以在一个声明中完成,还是必须在每种情况下单独完成?
答案1
如果你使用类似定理的环境,
\usepackage{amsthm}
然后你可以将它们定义为备注样式或定义样式,例如:
\theoremstyle{remark}
\newtheorem{ex}{Example}
如“定理样式”部分所述这里。
答案2
最后,在阅读了网上的一些帖子和资源后,我终于明白了示例环境可以定义为不同的字体和适当的缩进。
下面我给出了代码。为了保持可读性,我为每个参数都提供了注释,这让代码变得臃肿,但我的目的是让它保持可读且易懂
%in the preamble
\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage[T1]{fontenc}
%%%%% environment definition begins %%%%%
\newcounter{example}[chapter] %counter for example
\newenvironment{example} %name of environment
[1] %number of arguments for the environment
[Default value of argument if none provided]
{\refstepcounter{example} %be able to label
\par %starts the example in a new paragraph
\textbf{Example~\thechapter.\theexample } %how the example should like,
%bold here, Example 2.3
\textit{#1} %additional argument will be italisized
%all the codes here onwards specify the
% properties of the body of example
\fontfamily{pcr} \selectfont %font for body of example
\leftskip=1em \rightskip=2em %indentation for the body
\par %the body of example starts in a new paragraph
}
{\par %new paragraph when the body of example ends
\vspace{\baselineskip} %additional vertical spacing to
%show that example has ended
\noindent %stop anymore indentation
}
%%%%% environment definition ends %%%%
在第二章的某个地方记录了第四个例子
\begin{document}
%somewhere in the document
\begin{example}[This is an example]
The body of the example is here but this appears no different than the body of the section that follows. I need either different font or a different indentation to make it look like an example \\
this is a part of example %need to insert newline to break line
\end{example}
\textbf{this is not a part of example and now finally distinguishable }
\end {document}
结果如下:
传递给示例的参数以斜体显示,示例的主体相应缩进,使用不同的字体,并且在示例的末尾缩进停止,并且示例所在的节/小节继续按应有的方式运行。
希望这可以帮助。