2

% I need to know how I can keep this tikzpicture centered. It tends to shift to left and right.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[paperheight=14in,paperwidth=8.5in,margin=2in,heightrounded]{geometry}
\usepackage{geometry}
\usepackage{tikz}
\usepackage{amsfonts, amsmath, amsthm, amssymb} \usepackage[utf8]{inputenc}
\usepackage{dtklogos}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{mindmap,trees,shadows}
\usetikzlibrary{positioning,shapes,shadows, arrows}
\begin{document}
\thispagestyle{empty}
\hspace{-4.5cm}
\begin{minipage}[t]{1.20\linewidth}
\raggedright
\vspace{-4.0cm}
\Large\textbf{Where Are We Now?}\\% Title
\today
\end{minipage}

\centering
\begin{tikzpicture}[auto, node distance = 0.36cm, thick, every node/.style = {rectangle, minimum width= 34mm, rounded corners=2pt, font = \sffamily, black,top color = green!40!white, bottom color = green!20!white,drop shadow, minimum height = 0.5cm}]
\node[minimum height=0.3cm] (SWGDAM){\sffamily\bfseries{SWGDAM Guidelines for Validation of Probabilistic Genotyping Systems}};
\node[label= {[circle,  text width=0.25cm, top color=white, bottom color=white, yshift=0.17cm, xshift=-0.15cm, minimum height=0cm, minimum size=0.1cm] right:{\scriptsize4.2}}] (42)        [below = of SWGDAM, xshift=3cm, yshift=0cm]  {Comparative Study};
\node[label={[circle,  text width=0.25cm, top color=white, bottom color=white, yshift=0.17cm, xshift=-0.1cm, minimum height=0cm, minimum size=0.1cm] right:{\scriptsize4.1}}] (41)[below = of 42, xshift=0cm, yshift=0cm]  {Data Generation}; 
\node[label= {[circle,  text width=0.25cm, top color=white, bottom color=white, yshift=0.17cm, xshift=-0.1cm, minimum height=0cm, minimum size=0.2cm] right:{\scriptsize4.2.1}}]  (421)        [below = of 41] {Consistency};
 \node[label= {[circle,  text width=0.25cm, top color=white, bottom color=white, yshift=0.17cm, xshift=-0.1cm, minimum height=0cm, minimum size=0.25cm] right:{\scriptsize4.2.1.1}}] (4211)   [below  = of 421, top color=yellow, bottom color=yellow]        {Method Comparison};
\node[label= {[circle,  text width=0.25cm, top color=white, bottom color=white, yshift=0.17cm, xshift=-0.1cm, minimum height=0cm, minimum size=0.25cm] right:{\scriptsize4.2.1.2}}] (4212)   [below  = of 4211, top color=yellow, bottom color=yellow]        {Concordance};
 \node[label= {[circle,  text width=0.25cm, top color=white, bottom color=white, yshift=0.17cm, xshift=-0.15cm, minimum height=0cm, minimum size=0.1cm] right:{\scriptsize7}}] (intval)        [below = of SWGDAM, xshift=-2.0cm, yshift=-0.36cm, top color=gray!40!white, bottom color=gray!40!white]  {\bfseries{Internal Validation}};
\node[label= {[circle,  text width=0.25cm, top color=white, bottom color=white, yshift=0.17cm, xshift=-0.15cm, minimum height=0cm, minimum size=0.1cm] right:{\scriptsize7.1.1}}] (711b)        [below = of intval, xshift=0cm, yshift=0cm, top color=gray!20!white, bottom color=white]  {Template Concentration}; 
 \node[label= {[circle,  text width=0.25cm, top color=white, bottom color=white, yshift=0.17cm, xshift=-0.15cm, minimum height=0cm, minimum size=0.1cm] right:{\scriptsize7.1.2}}] (712b)        [below = of 711b, xshift=0cm, yshift=0cm, top color=gray!20!white, bottom color=white]  {Mixture Proportions};
 \node[label= {[circle,  text width=0.25cm, top color=white, bottom color=white, yshift=0.17cm, xshift=-0.15cm, minimum height=0cm, minimum size=0.1cm] right:{\scriptsize3333}}] (3333)        [left = of intval, xshift=-1cm, yshift=0cm, top color=gray!20!white, bottom color=white]  {3333};
\end{tikzpicture}
 \end{document}
2
  • What do you mean by left and right? It is much wider than the textblock, so it sticks into the right margin quite a bit. If you don't want to make it narrower, but center it on the textblock, you can use the techniques described in tex.stackexchange.com/questions/16582/… – Torbjørn T. Jan 12 '17 at 18:22
  • 1
    The figure is too large for your geometry. Try to use \resizebox to adjust it to your \linewidth. – Jérôme Dequeker Jan 12 '17 at 18:22
4

To see size of image in comparison to text width of document, add option showframe to options of the geometry package.

As already pointed other, image is to wide. They also suggest some solution how to reduce with post-action the image width. In this ideas the idea to use resizebox has serious weakness: reducing of images reduce fonts size too. It can happen that it become to small to be easy read.

For taken any measure it is appropriate to re-code image in more clear form, with common definition of styles which is than more easy manipulate in eventually redesign of table (which is to my opinion) only correct approach. On possible redesign of code is the following MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe,
            paperheight=14in,paperwidth=8.5in,
            margin=2in,heightrounded]{geometry}
%\usepackage{geometry}
%\usepackage{tikz}
\usepackage{amsfonts, amsmath, amsthm, amssymb} 
\usepackage[utf8]{inputenc}
%\usepackage{dtklogos}
\usepackage{tikz}
\usetikzlibrary{positioning,shadows}
\begin{document}
\thispagestyle{empty}
\hspace{-4.5cm}
\begin{minipage}[t]{1.20\linewidth}
\raggedright
\vspace{-4.0cm}
\Large\textbf{Where Are We Now?}\\
\today
\end{minipage}

\centering
\begin{tikzpicture}[%auto, thick, 
node distance = 3.6mm and 9mm, 
C/.style args = {#1/#2}{% Color
    top color = #1, bottom color=#2},
C/.default = green!40!white/green!20!white,
     N/.style = {% Node
    rectangle, rounded corners=2pt,  
    minimum width= 31mm, font = \sffamily\footnotesize, %black,
    drop shadow, minimum height = 5mm}, 
every label/.style = {shape=circle, fill=white, text width=4.5ex, align=center,
           inner sep=1pt, font=\sffamily\scriptsize, drop shadow,
           yshift=0.17cm, xshift=-0.15cm}
                                          ]
\node [N,C] (SWGDAM)    {\textbf{SWGDAM Guidelines for Validation 
                                 of Probabilistic Genotyping Systems}};
\node [N,C,label=right:4.2,
       below left=5mm and 0mm of SWGDAM.south east]     
                                            (42)    {Comparative Study};
\node[N,C,label=right:4.1,below=of 42]      (41)    {Data Generation};
\node[N,C,label=right:4.2.1,below=of 41]    (421)   {Consistency};
\node[N,C=yellow/yellow,
      label=right:4.2.1.1, below=of 421]   (4211)   {Method Comparison};
\node[N,C=yellow/yellow,
      label=right:4.2.1.2, below=of 4211]   (4212)  {Concordance};
\node[N,C=gray!40!white/gray!40!white, 
      label=right:7, left = of 42]      (intval)    {\textbf{Internal Validation}};
\node[N,C=gray!20!white/white,
      label=right:7.1.1,below = of intval]  (711b)  {Template Concentration};
 \node[N,C=gray!20!white/white,
       label=right:7.1.2,below = of 711b]   (712b)  {Mixture Proportions};
\node[N,C=gray!20!white/white,
      label=right:3333,left = of intval]    (3333)  {3333};
\end{tikzpicture}
    \end{document}

which gives:

enter image description here

Image is regardless to used \footnotesize font size still wider than text width. As solution seems to be consideration about break text in nodes into two line:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe,
            paperheight=14in,paperwidth=8.5in,
            margin=2in,heightrounded]{geometry}
\usepackage{amsfonts, amsmath, amsthm, amssymb} 
\usepackage[utf8]{inputenc}
%\usepackage{dtklogos} % not relevant
\usepackage{tikz}
\usetikzlibrary{positioning,shadows}
\begin{document}
\thispagestyle{empty}
\hspace{-4.5cm}
\begin{minipage}[t]{1.20\linewidth}
\raggedright
\vspace{-4.0cm}
\Large\textbf{Where Are We Now?}\\% Title
\today
\end{minipage}

\centering
\begin{tikzpicture}[%auto, thick, 
node distance = 3.6mm and 9mm, 
C/.style args = {#1/#2}{% Color
    top color = #1, bottom color=#2},
   C/.default = green!40!white/green!20!white,
     N/.style = {% Node
    rectangle, rounded corners=2pt, 
    minimum width= 24mm, font = \sffamily, 
    align=center, inner xsep=1ex,
    drop shadow, minimum height = 5mm}, 
every label/.style = {shape=circle, fill=white, text width=4.5ex, align=center,
           inner sep=1pt, font=\sffamily\scriptsize, drop shadow,
           yshift=0.17cm, xshift=-0.15cm}
                                          ]
\node [N,C,font=\bfseries\sffamily] (SWGDAM)   {SWGDAM Guidelines for Validation of\\
                                                Probabilistic Genotyping Systems};
\node [N,C,label=right:4.2,
       below=of SWGDAM.south east]     
                                            (42)    {Comparative\\ Study};
\node[N,C,label=right:4.1,below=of 42]      (41)    {Data\\ Generation};
\node[N,C,label=right:4.2.1,below=of 41]    (421)   {Consistency};
\node[N,C=yellow/yellow,
      label=right:4.2.1.1, below=of 421]   (4211)   {Method\\ Comparison};
\node[N,C=yellow/yellow,
      label=right:4.2.1.2, below=of 4211]   (4212)  {Concordance};
%
\node[N,C=gray!40!white/gray!40!white,font=\bfseries\sffamily,
      label=right:7, below = of SWGDAM]     (intval)    {Internal\\ Validation};
\node[N,C=gray!20!white/white,
      label=right:7.1.1,below = of intval]  (711b)  {Template\\ Concentration};
 \node[N,C=gray!20!white/white,
       label=right:7.1.2,below = of 711b]   (712b)  {Mixture\\ Proportions};
%
\node[N,C=gray!20!white/white,
      label=right:3333,below = of SWGDAM.south west]   (3333)  {3333};
\end{tikzpicture}
    \end{document}

enter image description here

4

As mentioned in the comments the picture is wider than the margins.

To know if the margin are overflown, enable the class option draft:

\documentclass[draft]{article}

This way, if something sticks out of the margin, you'll see a black bar indicating it in the margin.

To properly align it there are multiple options:

1. Adjust the drawing

Use the tikz keys scale, x,y, etc... to make the graphics smaller

2. Use resizebox to scale the drawing

Wrap your tikzpicture enviroment in a resized box:

\resizebox{\linewidth}{!}{\begin{tikzpicture} ... \end{tikzpicture}}

The \linewidth indicates the target width (Note that if the image is less wide than that it will be enlarged!), while ! computes the height to preserve the ratio.

3. Make the drawing overflow the margins symmetrically

This is accomplished by telling LaTeX that the width of your drawing is 0pt around its center, which can be accomplished by wrapping the tikzpicture environment in a makebox:

\makebox[0pt][c]{\begin{tikzpicture} ... \end{tikzpicture}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.