You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

108 lines
2.5 KiB

\documentclass[a4paper,landscape]{article}
\usepackage{geometry}
\pagestyle{empty}
\usepackage{xparse}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc}
\tikzset{
every node/.style = {
inner sep = 0pt,
anchor = north west,
}
}
\ExplSyntaxOn
\int_new:N \l_impose_repetitions_int
\int_new:N \l_impose_counter_int
\dim_new:N \l_impose_creep_dim
\int_new:N \l_impose_total_pages_int
\int_new:N \l_impose_total_pages_to_four_int
\cs_new:Npn \impose_get_page:nn #1#2 {
\int_compare:nT { ( #1 ) <= \l_impose_total_pages_int } {
\includegraphics [
width = 0.5\paperwidth,
page = #1,
] { #2 }
}
}
\NewDocumentCommand { \MakeBooklet } { O{0mm} m } {
\int_zero:N \l_impose_counter_int
\dim_zero:N \l_impose_creep_dim
\pdfximage { #2 .pdf }
\int_set:Nn \l_impose_total_pages_int
{ \the \pdflastximagepages }
\int_compare:nTF { \int_mod:nn { \l_impose_total_pages_int } { 4 } != 0 } {
\int_set:Nn \l_impose_total_pages_to_four_int
{ \l_impose_total_pages_int + 4 - \int_mod:nn { \l_impose_total_pages_int } { 4 } }
} {
\int_set_eq:NN \l_impose_total_pages_to_four_int \l_impose_total_pages_int
}
\int_set:Nn \l_impose_repetitions_int
{ \l_impose_total_pages_to_four_int / 2 }
\int_do_while:nn { \l_impose_counter_int < \l_impose_repetitions_int } {
\clearpage
\int_incr:N \l_impose_counter_int
\begin{tikzpicture}[remember~picture, overlay]
\node at ($
(current~page.north)
-
(\dim_use:N \l_impose_creep_dim, 0)
$) {
\impose_get_page:nn
{ \int_use:N \l_impose_counter_int }
{ #2 }
};
\node at ($
(current~page.north~west)
+
(\dim_use:N \l_impose_creep_dim, 0)
$) {
\impose_get_page:nn
{ \int_eval:n { \l_impose_total_pages_to_four_int - \l_impose_counter_int + 1 } }
{ #2 }
};
\end{tikzpicture}
\clearpage
\int_incr:N \l_impose_counter_int
\begin{tikzpicture}[remember~picture, overlay]
\node at ($
(current~page.north~west)
+
(\dim_use:N \l_impose_creep_dim, 0)
$) {
\impose_get_page:nn
{ \int_use:N \l_impose_counter_int }
{ #2 }
};
\node at ($
(current~page.north)
-
(\dim_use:N \l_impose_creep_dim, 0)
$) {
\impose_get_page:nn
{ \int_eval:n { \l_impose_total_pages_to_four_int - \l_impose_counter_int + 1 } }
{ #2 }
};
\end{tikzpicture}
\dim_set:Nn \l_impose_creep_dim {
#1 * \l_impose_counter_int / 2
}
}
}
\ExplSyntaxOff
\begin{document}
% #1 = Verschiebung pro Bogen (optional)
% #2 = Dateiname (ohne Endung!). Datei muss eine PDF sein!
\MakeBooklet[0.24mm]{calender}
\end{document}