# Add a figure title and x-axis label to a figure matrix created using pdfpages

### Background

I previously asked: Can I convert a 16 page pdf into an 8x2 matrix in LaTeX?

I ended up creating a 3x5 matrix of images from a 15 page pdf by compiling a document "foo.tex":

\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[landscape = false,
pages={1-15},
nup=3x8,
delta={10 10}]{myplots.pdf}
\end{document}

Which gives the document foo.pdf:

I have used the caption package to place captions on a separate page, as described in the answer to a separate question by putting this in the preamble:

\usepackage{caption}
\usepackage{letltxmacro}% http://ctan.org/pkg/letltxmacro
\captionsetup{labelsep=none}
\DeclareCaptionTextFormat{none}{} \captionsetup{labelsep=none,textformat=none}

And then include foo.pdf in my manuscript as a figure with the following command:

\begin{figure}[p]
\caption{This is my caption that will end up on another page}
\begin{center}
\includegraphics[width=0.9\textwidth]{foo.pdf}
\end{center}
\label{fig:foo}
\end{figure}
\end{document}

### Question

Now, I need to add a title and an x-axis label to the overall figure (not to the individual plots), how can I do this?

I have looked in the pgfpages documentation, and could not find any such feature.

### Updates / What I have tried

using , as suggested in the related question suggested by @percusse would work after adding ofset=10mm,10mm to the pdfpages command, except that it is not clear how to rotate the text 90 degrees for the x-axis. I have come up with a temporary "good-enough" solution and posted this as an answer

-
@jake to the overall figure; I created the individual figures in the R ggplot2 package, and I can manipulate the individual plots pretty easily. –  David Jun 26 '12 at 14:25
What is the relation between pdfpages and the x-axis label ? I think your solution is not related to plots per se. Why not using \caption{X-axis label}. –  percusse Jun 26 '12 at 14:35
You might need to use PSTricks or TikZ to place the figures in a coordinate axes. –  Stiff Jokes Jun 26 '12 at 14:39
@percusse The relation with pdfpages is only that I used it to create the figure, and I don't know if the solution is in the figure creation or when including it in the main document. Please re-tag as appropriate. I don't use caption mainly because the caption is on a separate page, as per publishers' instructions using the caption package, as described in the answer to a related question –  David Jun 26 '12 at 14:44
@percusse I have updated my question to reflect the use of the caption package. –  David Jun 26 '12 at 14:50
show 7 more comments

## 2 Answers

A solution with pagecommand option of \includepdf (and picture):

\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[landscape = false,
pages={1-15},
offset=-5mm -15mm,
nup=3x8,
delta={10 10},
pagecommand={
\begin{picture}(0,0)
\put (100,100) {\normalsize{\sffamily{This is my manually-centered title}}}
\end{picture}
},
]{myplots.pdf}
\end{document}

Same solution using tikz to center and rotate nodes:

\documentclass{article}
\usepackage{tikz}
\usepackage{pdfpages}
\begin{document}
\includepdf[landscape = false,
pages={1-15},
offset=-5mm -15mm,
nup=3x8,
delta={10 10},
pagecommand={
\thispagestyle{empty}
\begin{tikzpicture}[overlay,remember picture]
\node[font=\large\bfseries]
at ([yshift=-8mm]current page.north)
{This is my centered title};
\node[font=\large\bfseries,rotate=90]
at ([xshift=1in]current page.west)
{Y Label...};
\node[font=\large\bfseries]
at ([yshift=-6cm]current page.center)
{X Label...};
\end{tikzpicture}
},
]{myplots.pdf}

\end{document}

Here's the result (using a beamer document instead of myplots.pdf):

-
add comment

Here is the hacky answer that I have come up with, but it requires generating the figure first (foo.pdf) and then the figure with the title (foo_title.pdf); foo_title.pdf is the final figure to be incorporated into the manuscript.

1. generate foo.pdf with pdfpages[offset=-5mm -15mm]

\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[landscape = false,
pages={1-15},
offset=-5mm -15mm,
nup=3x8,
delta={10 10}]{myplots.pdf}
\end{document}

2. generate foo_title using the package and package to remove margins:

\documentclass{article}
\usepackage[percent]{overpic}
\usepackage{geometry}
\geometry{verbose,a4paper,tmargin=0cm,bmargin=0cm,lmargin=0cm,rmargin=0cm}

\begin{document}
\begin{overpic}{foo.pdf}
\put (18,98) {\normalsize{\sffamily{This is my manually-centered title}}}
\end{overpic}
\end{document}

Here is the resulting foo_title.pdf:

3. Include foo_title.pdf in manuscript

This solution lacks the following desirable features:

• do this in one, rather than three separate tex (and four pdf) files
• x-axis label with rotated text
• automatically centered title and x-axis label
-
add comment