
1 つの列のすべてがタイプライター フォントで表示される表を作成しようとしています。つまり、次のように実行する必要があります。
\begin{tabular} {| l | p{5cm} |}
\hline
\multicolumn{2}{|l|}{Sample Table} \\ \hline
\texttt{left a} & right a \\ \hline
\texttt{left b} & right b \\ \hline
\texttt{left c} & right c \\ \hline
\end{tabular}
しかし、すべての行に入力するのは避けたいのですが\texttt
、それを実現する方法はありますか?
答え1
あなたはarray
パッケージとその高度な列仕様。構文は
>{before-code} column-type <{after-code}
ここで、before-code
およびafter-code
は、問題の列の各セルの最初と最後で(それぞれ)実行されます。ここでは、
>{\ttfamily}l
結果的に、セルがタイプライター フォントでタイプセットされた左揃えの列が作成されます。
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular} {| >{\ttfamily}l | p{5cm} |}
\hline
\multicolumn{2}{|l|}{Sample Table} \\ \hline
left a & right a \\ \hline
left b & right b \\ \hline
left c & right c \\ \hline
\end{tabular}
\end{document}