I have a lot of tikzpicture
elements in my document. I want all the elements to be centered automatically without writing \begin{center}...\end{center}
. I found a solution to make a figure center by the following code:
\documentclass{memoir}
\usepackage[draft]{graphicx}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
% Solution 1 <--- Best for figures
\setfloatadjustment{figure}{\centering}
% Solution 2 <--- does not work
% \makeatletter
% \g@addto@macro\@floatboxreset{\centering}
% \makeatother
% % Solution 3 --- works
% \let\origfigure\figure
% \let\endorigfigure\endfigure
% \renewenvironment{figure}[1][tbph]{%
% \origfigure[#1]%
% \centering
% }{%
% \endorigfigure
% }
\begin{document}
The first paragraph.
\begin{figure}
\includegraphics{a.jpg}
\caption[Long caption]{Caption}
\label{pic-a}
\end{figure}
And the second.
\begin{tikzpicture}
\node[rectangle,
draw = blue,
text = olive,
fill = gray!30,
minimum width = 5cm,
minimum height = 1cm] (r) at (0,0) {Rectangle};
\end{tikzpicture}
\begin{tikzpicture}
\node[isosceles triangle,
draw,
fill=cyan!30,
minimum size =3cm] (T) at (0,0) {};
\end{tikzpicture}
\end{document}
However, my tikzpicture
elements are not effected. How can I do that (to set all the tikzpictures to be centered automatically without using \begin{center}...\end{center}
each time?