예제에서 \ttfamily 글꼴을 체계적으로 사용하세요.

예제에서 \ttfamily 글꼴을 체계적으로 사용하세요.

내 문제는 제목과 같습니다. \ttfamily 글꼴을 사용하고 싶습니다.예시로만 체계적으로, \documentclass{amsbook} 내부. 이런 식으로 주변의 텍스트와 예를 구별하고 싶기 때문에 이렇게 합니다.

이상적인 방법은 다음과 같아야 합니다 \newtheorem{example}[thm]{Example}[\ttfamily](불행히도 작동하지 않습니다).

답변1

빠르고 쉬운 방법은 새로운 정리 스타일(즉)을 정의하기 위한 '공식' 명령을 우회 하고 글꼴 설정만 있는 \newtheoremstyle내부 명령을 사용하여 스타일을 정의하는 것입니다 . \th@somestyle이는 예를 들어 내장 definition스타일이 의 소스에 정의되는 방식과 유사합니다 amsthm.

텔레타이프는 일반적으로 고정된 너비의 문자를 가지므로 일반적으로 줄이 고르지 않습니다. 정렬된 텍스트를 원할 경우 일부 글꼴 크기를 수정할 수 있습니다.http://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}

결과:

여기에 이미지 설명을 입력하세요

관련 정보