## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Drawn Picture not centered Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
sgu
Posts: 5
Joined: Sun Jun 30, 2013 6:25 am

### Drawn Picture not centered

Hi all,

the tikzpicture environment seems to fail to center sometimes. The following is such an example.
1. \documentclass{article}
2. \usepackage{tikz}
4.
5. \begin{document}
6. \begin{figure}[!htb]
7. \centering
8. \begin{tikzpicture}
9. \draw[help lines] (-6.0,-6.0) grid (6.0,6.0);
10. \node[align=center, fill=red!20, rounded corners=14pt, minimum height=2cm, minimum width=4cm] (chbox) at (0,0) {A};
11. \node[align=center, fill=red!20, rounded corners=14pt, minimum height=2cm, minimum width=4cm] (meshbox) at (-6.0,0) {B};
12. \node[align=center, fill=red!20, rounded corners=14pt, minimum height=2cm, minimum width=4cm] (imagebox) at (6.0,0) {C};
13. \end{tikzpicture}
14. \caption{Figure caption}
15. \label{fig:dummy}
16. \end{figure}
17. \end{document}

Any fix? Thanks.
Last edited by localghost on Sun Jun 30, 2013 9:04 am, edited 1 time in total.
Reason: Longer passages of source code are tagged as code block, not as in-line code.

Tags:

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
Very good example. It makes the probable cause comprehensible at first sight and thus it's quite easy to fix it.

The picture itself is simply too wide. You should get a corresponding warning in the log file (*.log). Simply scale it down by the scale option for the tikzpicture environment. The option is described in Section 22.3 of the PGF/TikZ user guide.

Best regards and welcome to the board
Thorsten
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

sgu
Posts: 5
Joined: Sun Jun 30, 2013 6:25 am
The scale option seems not to work well with the minimum height and minimum width options.
1. \documentclass{article}
2. \usepackage{tikz}
4.
5. \begin{document}
6. \begin{figure}[!htb]
7. \centering
8. \begin{tikzpicture}[scale=0.3]
9. \draw[help lines] (-6.0,-6.0) grid (6.0,6.0);
10. \node[align=center,fill=red!20,minimum height=2,minimum width=4] (chbox) at (0,0) {A};
11. \node[align=center,fill=red!20,minimum height=2,minimum width=4] (meshbox) at (-6.0,0) {B};
12. \node[align=center,fill=red!20,minimum height=2,minimum width=4] (imagebox) at (6.0,0) {C};
13. \end{tikzpicture}
14. \caption{Figure caption}
15. \label{fig:dummy}
16. \end{figure}
17. \end{document}

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
Add the transform shape option either as global option to the tikzpicture environment or locally for every single \node. The option is described in Section 16.7 of the PGF/TikZ user guide.
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

sgu
Posts: 5
Joined: Sun Jun 30, 2013 6:25 am
That solves the problem, thank you.
PGF has a lot of options and it looks like the PGF/tikz manual have very good examples to demonstrate the capability of the package but doesn't list all the options and all values for a option. And the PGF package has massive source codes. Any recommended way to find out the complete list of the options and all possible values for a given option? Thank you.

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
sgu wrote:[…] PGF has a lot of options and it looks like the PGF/tikz manual have very good examples to demonstrate the capability of the package but doesn't list all the options and all values for a option. […] Any recommended way to find out the complete list of the options and all possible values for a given option? […]

Actually the PGF/TikZ user guide lists all available options. How else would you find the right one for a problem? Perhaps you should browse the user guide by topic, not by keyword.
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

### Who is online

Users browsing this forum: No registered users and 10 guests