displaymath内の配列の後にキャプションを追加する

displaymath内の配列の後にキャプションを追加する

私は次のように真理値表を書いています:

\begin{displaymath}
\begin{array}{|c c|c|}
p & q & p \land q \\
\hline
1 & 1 & 1 \\
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 0 \\
\end{array}
\end{displaymath}

そして、テーブルの後に、テーブルの内容を説明するキャプションを付けたいと思います。 と の両方を試しましたが、\captionコンパイルcaptionofされません。

答え1

これは、あなたの望むことですか?

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools,amssymb}
\usepackage{caption}

\begin{document}

\bgroup\setlength{\belowdisplayskip}{-2ex}
\begin{gather*}
\begin{array}{|cc|c|}
p & q & p \land q \\
\hline
1 & 1 & 1 \\
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 0 \\
\end{array}
\shortintertext{%
\captionof{table}{This is my table with caption}}
\end{gather*}
\egroup
Some text. Some more text. Some more text. Some more text. Some more text.

\end{document} 

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

関連情報