# Is this the best way to make two landscape pages for each portrait page?

With the new age I get large amounts of text in pdf format to read and assess. Initially I used perl code to add headers and then create a tex file that has a toc and a section per submission which I included with includepdf ...

Recently I moved over to use only luacode and just picked up a list of files with luacode, so the same result sans the extra headers.

So I got tired of reading it on a standard screen and would like to use the TV screen which is bigger. So I searched and came accross Heiko Oberdiek's solution to do the inverse at Insert external PDF pages with adapted size, position and margins.

I modified it resulting in:

\documentclass[a4paper,landscape]{article}
\usepackage{graphicx}
\usepackage[margin=0pt]{geometry}

\makeatletter
\newcounter{imagepage}
\newcommand*{\foreachpage}[2]{%
\begingroup
\sbox0{\includegraphics{#1}}%
\xdef\foreachpage@num{\the\pdflastximagepages}%
\endgroup
\setcounter{imagepage}{0}%
\@whilenum\value{imagepage}<\foreachpage@num\do{%
\stepcounter{imagepage}%
#2\relax
}%
}
\makeatother

\newcommand*{\upperpart}[2]{%
\begingroup
\centering
\includegraphics[
scale=1.41,
trim=0 150mm 0  0,
page=#2,
width=\textwidth,
]{#1}%
\newpage
\endgroup
}

\newcommand*{\lowerpart}[2]{%
\begingroup
\centering
\includegraphics[
scale=1.41,
trim=0  0  0 140mm,
page=#2,
width=\textwidth,
]{#1}%
\newpage
\endgroup
}

\newcommand{\splitdoc}[1]%
{
\begingroup
\begin{center}
\foreachpage{#1}{%
\upperpart{#1}{\value{imagepage}}
\lowerpart{#1}{\value{imagepage}}
}
\end{center}
\endgroup
}

\begin{document}
\splitdoc{example}
\end{document}


I especially want a single command as I use the same code in another document where I collect all the files, sort them and then add a section per submitter.

The center of the luacode which I use is eventually a for loop that execute the following per submission [the submitters each have a directory(s) and it contains one or more files (f)]:

tex.print("\\splitdoc{\\detokenize{"..s.."/"..f..'}}')


This works fine, apart from the fact that figure now sometimes are split across pages, but that I expected from the onset and can live with that.

I was wondering if anybody can suggest a better way to achieve the same result?

-
The 150mm and 145mm is to ensure that sentences do not get cut in half with both halves being split and unintelligible. –  Louis Sep 19 at 19:36