3

I would like to put the bar chart over the table. I cannot do this and don't understand why.

\documentclass[border=10pt]{standalone}
\usepackage{verbatim}
\usepackage{pgfplot}
\pgfplotsset{width=7cm,compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    x tick label style={
        /pgf/number format/1000 sep=},
    ylabel=Year,
    enlargelimits=0.05,
    legend style={at={(0.5,-0.1)},
    anchor=north,legend columns=-1},
    ybar interval=0.7,
]
\addplot 
    coordinates {(2012,408184) (2011,408348)
         (2010,414870) (2009,412156) (2008,415 838)};
\addplot 
    coordinates {(2012,388950) (2011,393007) 
        (2010,398449) (2009,395972) (2008,398866)};
\legend{Men,Women}
\end{axis}
\end{tikzpicture}
\begin{tabular}{c|c|c|c}
{\sc Dossiers} & {\sc Pages} & {\sc \'Echéances} & {\sc Label}\\
\hline
\hline
Histoire des Sciences (1) & 15p mini & 01/01/17 & A\\
\hline
Histoire des Sciences (2) & 15p mini & 01/01/17 & B\\
\hline
Neurosciences & 10 (2x5) & 01/01/17 & C\\
\hline
Histoire         & 6-10p    & 01/01/17 & D\\
\hline
Histoire des SVT & 10p      & " + 2 sem. & E 
\end{tabular}
\end{document}
Bernard
  • 271,350

2 Answers2

5

As an aside, you could also place the tabular in a \node inside the tikzpicture. Further, note that \sc is deprecated in favor of \scshape, see Does it matter if I use \textit or \it, \bfseries or \bf, etc.

\documentclass[border=10pt]{standalone}
\usepackage{booktabs} % added for \toprule,\midrule,\bottomrule
\usepackage{array} % added for the *{4}{c} syntax
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    x tick label style={
        /pgf/number format/1000 sep=},
    ylabel=Year,
    enlargelimits=0.05,
    legend style={at={(0.5,-0.1)},
    anchor=north,legend columns=-1},
    ybar interval=0.7,
]
\addplot 
    coordinates {(2012,408184) (2011,408348)
         (2010,414870) (2009,412156) (2008,415 838)};
\addplot 
    coordinates {(2012,388950) (2011,393007) 
        (2010,398449) (2009,395972) (2008,398866)};
\legend{Men,Women}
\end{axis}
\node [above] at (current bounding box.north) {%
\begin{tabular}{*{4}{c}}
\toprule
\scshape Dossiers & \scshape Pages & \scshape \'Echéances & \scshape Label\\
\midrule
Histoire des Sciences (1) & 15p mini & 01/01/17 & A\\
Histoire des Sciences (2) & 15p mini & 01/01/17 & B\\
Neurosciences & 10 (2x5) & 01/01/17 & C\\
Histoire         & 6--10p    & 01/01/17 & D\\
Histoire des SVT & 10p      & " + 2 sem. & E  \\
\bottomrule
\end{tabular}
};
\end{tikzpicture}
\end{document}

enter image description here

Torbjørn T.
  • 206,688
4

tikzpicture and tabular have no special spacing rules, they are just positioned like big letters.

you have

X
Y

which makes

X Y

and you want

X

Y

which makes

X

Y

If using standalone class you need

\documentclass[border=10pt,varwidth]{standalone}

varwidth for any vertical mode constructs.

David Carlisle
  • 757,742