Page LayoutDouble page: Figures on even pages, text on odd pages

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Muffe
Posts: 1
Joined: Fri Oct 22, 2010 10:06 pm

Double page: Figures on even pages, text on odd pages

Post by Muffe »

I am writing a double-page layout document with many graphics, figures and graphs. I do not think latex is putting these in their correct spot, and want to make a special page layout: Have all the text on the odd pages and all the illustration on the even pages. If there is no illustrations, the even pages should be left blank (except headers and footers).

I guess it's possible to do in some way or another, the question is how to do it?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Martigan
Posts: 2
Joined: Tue May 17, 2011 12:13 pm

Double page: Figures on even pages, text on odd pages

Post by Martigan »

I have an answer; I hope it is not too late and it fits your needs and those of others around.

It is tailored to work with a book class with the oneside option activated.

First thing first, insert a blank page between every text page automatically (or a picture if a picture is defined beforehand). Write in the preamble:

Code: Select all

\usepackage{afterpage}

\makeatletter
\newcommand\@addfig{\relax}
\newcommand\addfig[1]{\global\long\def\@addfig{#1}}
\newcommand\@putfig{\@addfig\addfig{\relax}}
\newcommand\blankpage{%
\null
\vfill
\@putfig%
\vfill
\thispagestyle{empty}% BEWARE, if you want the header and footer, you should put the correct style here
\clearpage%
\addtocounter{page}{-1}% BEWARE, if you want the left pages to be numbered, don't put this line, this is intended to have picture page with the same number as the facing text page
\afterpage{\blankpage}}
\makeatother
And after the \begin{document}

Code: Select all

\afterpage{\blankpage}
Then, in the text anywhere in the page preceding the one we want to insert the picture on, if you want to insert a picture or a table (if you put nothing, a blank page will appear):

Code: Select all

\addfig{%
\centering
\includegraphics[scale=1]{Image1}
\caption{Test}
\label{Ima1}
}
You can note that I did not use a figure environment in order to put the figure in the middle of the blank page more easily.

You have to redefine \caption in order for it to work outside a float.

Very classic with that in the preamble:

Code: Select all

\makeatletter
\def\@captype{figure}
\makeatother
It does not work as well with tables AND figures (then you have to create other kinds of caption commands - doable of course, in order not to mix them).

You will have:
- Text only on right side pages
- Images only on left side pages
- Correct list of figures (and tables as well if you tweak it a bit)
- The correct numeration of your pages if you manage the pagestyle and stepcounter correctly.

I found the most important part of the process (the blankpage macro) thanks to Danie Els on an other forum.
Ben
Posts: 2
Joined: Tue Oct 25, 2011 10:27 am

Double page: Figures on even pages, text on odd pages

Post by Ben »

Thank you for this very useful information I was exactly looking for!

To go further with the discussion, I would like to handle 2 additional features:
  • the suppression of blank pages automaticly inserted by book,
  • the possibility to switch between figure and table captions.
Regarding the first, 3 blank pages are added before a new chapter (probably also before a new part) where only 1 should be. I managed to remove one redefining \chapter as follows (removing the first line involving \clearpage) but not the other.

Code: Select all

\renewcommand\chapter{
                    \thispagestyle{plain}%
                    \global\@topnum\z@
                    \@afterindentfalse
                    \secdef\@chapter\@schapter}
For the second, I defined a new command \switchcaption as follows which I call before and after a table respectively with "table" and "figure" as argument.

Code: Select all

\newcommand\switchcaption[1]{\def\@captype{#1}}
By the way, I would be very interested in better understanding
  • when it is useful to use directly \def instead of \(re)newcommand (\newcommand\@captype{figure} seems to work just as well as \def\@captype{figure}),
  • when it is needed to work within \makeatletter \makeatother (apparently \newcommand works differently in both cases: it "reads" the new command name with subsequent braces outside \makeatletter \makeatother and without braces otherwise),
  • why \addfig definition needs to statements (one for \@addfig and another apparently for its argument).
Thank you very much in advance for your help!

PS: the answer by Danie Els is avaiable at http://tex.stackexchange.com/questions/ ... nly-on-rig
Ben
Posts: 2
Joined: Tue Oct 25, 2011 10:27 am

Double page: Figures on even pages, text on odd pages

Post by Ben »

I finally worked out more elegant (and suitable) solutions to the above-mentionned issues.
  • The blank pages were actually linked to the page break inserted by `\include` (I am writing a thesis...). Using `\input` instead solves the problem (without redefining `\chapter`). In addition, I managed to avoid blank pages at the end of the document redefining `\blankpage` to stop recursion (`\renewcommand{\blankpage}{}`).
  • To define table captions (which are much less numerous than figure ones), I realised that I could use the command `\captionof` provided by the caption package I am using anyway.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Double page: Figures on even pages, text on odd pages

Post by localghost »

Ben wrote:I finally worked out more elegant (and suitable) solutions to the above-mentionned issues.
  • The blank pages were actually linked to the page break inserted by `\include` (I am writing a thesis...). Using `\input` instead solves the problem (without redefining `\chapter`). In addition, I managed to avoid blank pages at the end of the document redefining `\blankpage` to stop recursion (`\renewcommand{\blankpage}{}`).
  • To define table captions (which are much less numerous than figure ones), I realised that I could use the command `\captionof` provided by the caption package I am using anyway.
It would be very kind if you mention when doing a crossposting [1]*. This is only fair because it prevents others from double efforts and waste of time.
Martigan wrote:I found the most important part of the process (the blankpage macro) thanks to Danie Els on an other forum.
The same applies to this [2]. Such behaviour is contra-productive.


* According to the rules you are obliged to do so.

[1] {TeX} SX – Figures on left pages, text on right ones with class book (cont.)
[2] {TeX} SX – Figures on left pages, text on right ones with class book, numbering only on right pages
Post Reply