
Mi problema es como en el título: quiero usar la fuente \ttfamilysistemáticamente solo en ejemplos, dentro de \documentclass{amsbook}. Hago esto porque quiero distinguir los ejemplos del texto de esta manera.
La forma ideal debería ser algo como \newtheorem{example}[thm]{Example}[\ttfamily]
(que lamentablemente no funciona).
Respuesta1
Una forma rápida y sencilla es omitir el comando "oficial" para definir un nuevo estilo de teorema (que es \newtheoremstyle
) y definir un estilo usando el comando interno \th@somestyle
con solo la configuración de fuente. Esto es similar a cómo, por ejemplo definition
, se define el estilo integrado en la fuente de amsthm
.
El teletipo normalmente tiene caracteres de ancho fijo, por lo que las líneas suelen ser desiguales. Si desea texto justificado, puede modificar algunas de las dimensiones de la fuente, 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: