
Meu problema é como no título: quero usar a fonte \ttfamilysistematicamente apenas em exemplos, dentro de \documentclass{amsbook}. Faço isso porque quero distinguir exemplos do texto dessa maneira.
A forma ideal deveria ser algo parecido \newtheorem{example}[thm]{Example}[\ttfamily]
(o que infelizmente não funciona).
Responder1
Uma maneira rápida e fácil é ignorar o comando 'oficial' para definir um novo estilo de teorema (que é \newtheoremstyle
) e definir um estilo usando o comando interno \th@somestyle
apenas com a configuração da fonte. Isso é semelhante a como, por exemplo, o estilo integrado definition
é definido na fonte do amsthm
.
O teletipo normalmente possui caracteres de largura fixa, portanto as linhas geralmente são irregulares. Se desejar texto justificado, você pode modificar algumas das dimensões da fonte, consultehttp://texblog.net/latex-archive/plaintex/full-justification-with-typewriter-font/.
MWE:
\documentclass{amsbook}
\usepackage{amsthm}
\makeatletter
\def\th@example{%
\ttfamily % body font
\fontdimen2\font=0.4em% interword space
\fontdimen3\font=0.2em% interword stretch
\fontdimen4\font=0.1em% interword shrink
\fontdimen7\font=0.1em% extra space
}
\makeatother
\newtheorem{thm}{Theorem}
\theoremstyle{example}
\newtheorem{example}[thm]{Example}
\begin{document}
This is an example:
\begin{example}
An example can be short, or long, such as an entire line this is repeated a few times.
An example can be short, or long, such as an entire line this is repeated a few times.
An example can be short, or long, such as an entire line this is repeated a few times.
\end{example}
This is a theorem:
\begin{thm}
P is either short or long.
A theorem can be long, such as an entire line this is repeated a few times.
A theorem can be long, such as an entire line this is repeated a few times.
A theorem can be long, such as an entire line this is repeated a few times.
\end{thm}
\end{document}
Resultado: