同じテーブルに 2 つの異なるフォントがある

同じテーブルに 2 つの異なるフォントがある

私の目標は、左側に PCR フォントを使用し、右側に通常のフォント (たとえば、ssfamily フォント) を使用することです。これは、XeTeX を使用せずに可能ですか? なぜこれが必要なのか自問自答すると、常に を使用せずに、左側 (コマンド/関数) に説明を右側に表示したいのです\texttt{}

\documentclass[a4paper]{article}
\usepackage{tabularx} % in the preamble
\usepackage[a4paper, top=3cm, bottom=3cm, left=3cm, right=3cm, marginparwidth=2cm, headsep=1.2cm]{geometry} % layout

\begin{document}
% ....
\begin{table}[ht!]
 \fontfamily{pcr}\selectfont
\begin{tabularx}{\textwidth}{X X}
  \textbf{Function} & \textbf{Meaning} \\
\hline
asdf & ATFD is more than a few\\
Class that is large and complex & WMC is high\\
Class that has a lot of methods that only operate on a proper subset of the instance variable set & TCC is low\\
\end{tabularx}
\end{table}
\end{document}

答え1

これは完璧に動作します

\documentclass[a4paper]{article}
\usepackage{tabularx} % in the preamble
\usepackage[a4paper, top=3cm, bottom=3cm, left=3cm, right=3cm, marginparwidth=2cm, headsep=1.2cm]{geometry} % layout

\begin{document}
% ....
\begin{table}[ht!]

\begin{tabularx}{\textwidth}{>{\ttfamily}X X}
  \textbf{Function} & \textbf{Meaning} \\
\hline
asdf & ATFD is more than a few\\
Class that is large and complex & WMC is high\\
Class that has a lot of methods that only operate on a proper subset of the instance variable set & TCC is low\\
\end{tabularx}
\end{table}
\end{document}

関連情報