Zwei verschiedene Schriftarten in derselben Tabelle

Zwei verschiedene Schriftarten in derselben Tabelle

Mein Ziel ist es, auf der linken Seite den PCR-Font zu verwenden und auf der rechten Seite soll es der normale Font sein (z.B. ssfamily-Font). Ist das möglich, ohne XeTeX zu verwenden? Falls du dich fragst, warum das notwendig ist, ich möchte auf der linken Seite (Befehle/Funktionen) auf der rechten Seite eine Beschreibung, ohne immer zu verwenden \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}

Antwort1

Das funktioniert einwandfrei

\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}

verwandte Informationen