TransWikia.com

Different text on last page

TeX - LaTeX Asked on August 14, 2021

I want to add one of two different texts, depending on whether it appears on the last page.

I tried this:

documentclass{article}
usepackage[angle=0, opacity=1, scale=1,position={0,0}]{background}
usepackage{lastpage}

setlength{parskip}{6cm}

begin{document}
SetBgContents{
ifnumthepage=pageref{LastPage} This is the last pageelse More pages followfi
}

A lot of paragraphs

A lot of paragraphs

A lot of paragraphs

A lot of paragraphs

A lot of paragraphs

A lot of paragraphs

end{document}

But this fails when the .aux file is not yet created with:

! Missing number, treated as zero.
<to be read again>
                   protect
l.22 A
       lot of paragraphs

I think because then pageref{LastPage} is ?? which I cannot compare using ifnum.

How can I make this work?

One Answer

Solved it by using the getpagerefnumber command of the refcountpackage:

usepackage{refcount}

...

ifnumthepage=getpagerefnumber{LastPage} This is the last pageelse More pages followfi

Answered by AndreKR on August 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP