Wie kann ich eine Tabelle oder in meinem Fall ein Tikzbild horizontal zentrieren und dabei die Ränder ignorieren? Mein Tikzbild ist etwas zu groß, sodass es nicht richtig zentriert ist (ragt etwas zu weit in den rechten Rand hinein, aber wenn es richtig zentriert ist, ist es weniger).
ich habe es versucht
\makebox[\textwidth][c]{}
aber ich bekomme nur eine Menge Fehlermeldungen.
Antwort1
Fügen Sie ampersand replacement=\&
die tikzpicture
Optionen hinzu und ändern Sie sie alle &
in Ihrem tikzpicture
( \&
siehe Abschnitt17.5 Überlegungen zu aktiven Charakterendes pgf
Handbuchs):
\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}
Wenn Sie eine Überschrift wünschen, können Sie ein minipage
und den \captionof
Befehl aus den Paketen caption
oder verwenden capt-of
(Sie können keinen Float innerhalb eines verwenden \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}