テーブル、または私の場合は余白を無視して tikzpicture を水平方向に中央に配置するにはどうすればよいでしょうか。私の tikzpicture は少し大きすぎるため、適切に中央に配置されません (右余白に少しはみ出していますが、適切に中央に配置されていれば、それよりも小さくなります)。
私はもう試した
\makebox[\textwidth][c]{}
しかし、たくさんのエラーが発生します。
答え1
ampersand replacement=\&
オプションを追加しtikzpicture
、すべて&
のtikzpicture
をに変更します\&
(セクションを参照)17.5 アクティブキャラクターに関する考慮事項マニュアルのpgf
):
\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\lipsum[2]
\noindent\makebox[\textwidth]{%
\begin{tikzpicture}[ampersand replacement=\&]
\matrix [matrix of nodes]
{
8 \& 1 \& 6 \& 8 \& 1 \& 6 \& 8 \& 1 \& 6 \& 6 \& 8 \& 1 \& 6 \& 6 \& 8 \& 1 \& 6 \& 6 \& 8 \& 1 \& 6 \& 6 \& 8 \& 1 \& 6 \& 6 \& 8 \& 1 \& 6 \& 6 \& 8 \& 1 \& 6 \& 6 \& 8 \& 1 \& 6 \\
};
\end{tikzpicture}%
}
\end{document}
キャプションを付けたい場合は、 または パッケージの と コマンドを使用できます(内minipage
でフロートを使用することはできません)。\captionof
caption
capt-of
\makebox
\documentclass{article}
\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\noindent\makebox[\textwidth]{%
\begin{minipage}{2\textwidth}
\centering
\begin{tikzpicture}[ampersand replacement=\&]
\matrix [matrix of nodes]
{
8 \& 1 \& 6 \& 8 \& 1 \& 6 \& 8 \& 1 \& 6 \& 6 \& 8 \& 1 \& 6 \& 6 \& 8 \& 1 \& 6 \& 6 \& 8 \& 1 \& 6 \& 6 \& 8 \& 1 \& 6 \& 6 \& 8 \& 1 \& 6 \& 6 \& 8 \& 1 \& 6 \& 6 \& 8 \& 1 \& 6 \\
};
\end{tikzpicture}
\captionof{figure}{Test caption}
\end{minipage}%
}
\end{document}