我將使用乳膠創建以下類似程式碼的字串,具有相同的背景(灰色)、字體等。
我用的是listings
包裝,但裡面
\begin{lstlisting}...\end{lstlisting}
我無法使用表格環境。
答案1
如果您必須輸入所有內容,可以使用tabular
打字機 ( \ttfamily
) 字體。在下一個程式碼中我使用了tcolorbox
提供彩色盒裝背景。
\documentclass[a4paper]{article}
\usepackage[skins]{tcolorbox}
\begin{document}
\begin{tcolorbox}[fontupper=\small\ttfamily, colback=gray!10, arc=0pt]
\begin{tabular}{llll}
byte\# & hexadecimal & text or \\
(hex) & & value & Meaning\\
0: & 47 49 46 \\
& 37 39 61 & GIF89a & Header\\
&&& Logical Screen Descriptor\\
6: & 03 00 & 3 & - logical screen width in pixels\\
\end{tabular}
\end{tcolorbox}
\end{document}