Seite 1 von 1

Ifnum im NewCommand

Verfasst: Sa 26. Mär 2022, 01:38
von Sam85
Hallo,

ich wollte in dem Command abfragen wie viele Seiten es sind. Leider klappt das so nicht. Kann ich das mit dem Ifnum erreichen und wenn ja, wie muss ich das richtig setzen. Und wenn nein, welche Alternativen habe ich?

Freue mich auf eine Rückmeldung. Danke schön.
\newcommand{\includepdfwithheader}[4]{%
	\pdfximage{anhang/#3.pdf}
	\ifnum \the\pdflastximagepages > 1
	{\includepdf[%
		pages=1,
		frame=true,
		pagecommand=\textbf{\autoref{#4:#3}{:}\space{#3}},
		scale={#1},
		link=true,
		addtolist={1,#2,#3,#4:#3}]{anhang/#3.pdf}
	\includepdf[%
		pages={2,last},
		frame=true,
		pagecommand={},
		scale={#1},
		link=false]{anhang/#3.pdf}
	}
	\else
		{\includepdf[%
		pages=1,
		frame=true,
		pagecommand=\textbf{\autoref{#4:#3}{:}\space{#3}},
		scale={#1},
		link=true,
		addtolist={1,#2,#3,#4:#3}]{anhang/#3.pdf}
	}
}

Re: Ifnum im NewCommand

Verfasst: Sa 26. Mär 2022, 13:38
von Sam85
Ok konnte es selbst lösen. Danke dennoch.
\newcommand{\includepdfwithheader}[4]{%
	\pdfximage{anhang/#3.pdf}
	\ifnum \the\pdflastximagepages > 1 {% 
		\includepdf[%
			pages=1,
			frame=true,
			pagecommand=\textbf{\autoref{#4:#3}{:}\space{#3}},
			scale={#1},
			link=true,
			addtolist={1,#2,#3,#4:#3}]{anhang/#3.pdf}
		\includepdf[%
			pages={2,last},
			frame=true,
			pagecommand={},
			scale={#1},
			link=false]{anhang/#3.pdf}
		}
	\else {%
		\includepdf[%
			pages=1,
			frame=true,
			pagecommand=\textbf{\autoref{#4:#3}{:}\space{#3}},
			scale={#1},
			link=true,
			addtolist={1,#2,#3,#4:#3}]{anhang/#3.pdf}
		}
	\fi
}

Re: Ifnum im NewCommand

Verfasst: Di 3. Mai 2022, 15:57
von Sam85
Eine Korrektur noch, es muss pages={2-last} sein.
\newcommand{\includepdfwithheader}[4]{%
	\pdfximage{anhang/#3.pdf}
	\ifnum \the\pdflastximagepages > 1 {% 
		\includepdf[%
			pages=1,
			frame=true,
			pagecommand=\textbf{\autoref{#4:#3}{:}\space{#3}},
			scale={#1},
			link=true,
			addtolist={1,#2,#3,#4:#3}]{anhang/#3.pdf}
		\includepdf[%
			pages={2-last},
			frame=true,
			pagecommand={},
			scale={#1},
			link=false]{anhang/#3.pdf}
		}
	\else {%
		\includepdf[%
			pages=1,
			frame=true,
			pagecommand=\textbf{\autoref{#4:#3}{:}\space{#3}},
			scale={#1},
			link=true,
			addtolist={1,#2,#3,#4:#3}]{anhang/#3.pdf}
		}
	\fi
}