Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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 '13 at 19:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.