背景色付きのコードのような文字列、表形式の環境を使用する

背景色付きのコードのような文字列、表形式の環境を使用する

同じ背景 (グレー)、フォントなどを使用して、LaTeX を使用して次のコードのような文字列を作成します。どうすればこれを実現できますか?

ここに画像の説明を入力してください

listingsパッケージを使用しましたが、内部に

\begin{lstlisting}...\end{lstlisting}

表形式の環境が使えませんでした。

答え1

すべて入力する必要がある場合は、tabulartypewriter(\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}

ここに画像の説明を入力してください

関連情報