7

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:

enter image description here

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 LeBauer 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. – kiss my armpit 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 LeBauer Jun 26 '12 at 14:44
  • @percusse I have updated my question to reflect the use of the caption package. – David LeBauer Jun 26 '12 at 14:50
  • @Forgiver I have updated the tags to include [tag:pstricks] and [tag:tikz-pgf] – David LeBauer Jun 26 '12 at 14:51
  • I think you can just annotate the image and use your regular solution. One possibility is to put it in a TikZ node but there are other ways. See what I mean in http://tex.stackexchange.com/questions/20792/how-to-superimpose-latex-on-a-picture or http://tex.stackexchange.com/questions/20792/how-to-superimpose-latex-on-a-picture Note that this will happen inside the figure environment so no complication would be visible to caption or other mechanisms. If this is a suitable solution then it's quite simple to achieve. – percusse Jun 26 '12 at 14:52
  • @percusse thanks for the links, but you only posted one link two times - did you intend to post a link to a different question? – David LeBauer Jun 26 '12 at 15:03
  • Oopa sorry here is the other one http://tex.stackexchange.com/questions/9559/drawing-on-an-image-with-tikz – percusse Jun 26 '12 at 15:22
  • Have you try the pagecommand option of \includepdf? In its argument, you can add all the necessary content (using overpic for example). – Paul Gaborit Jul 02 '12 at 23:06
  • @PolGab I am not looking to add anything to each page in the source pdf, just to add text to the overall figure. – David LeBauer Jul 03 '12 at 02:09
  • @David pagecommand option is used to add something to the overall figure. Look at my answer... – Paul Gaborit Jul 03 '12 at 11:18

2 Answers2

4

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):

enter image description here

Paul Gaborit
  • 70,770
  • 10
  • 176
  • 283
3

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:

    enter image description here

  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