Page Layout ⇒ Instead of invoking \clearpage, how to update \thepage soon?
Instead of invoking \clearpage, how to update \thepage soon?
I want to invoke \thepage in any pages. Unfortunately, sometimes the printed page number is out of sync with the \thepage.
Actually we can flush the buffer by calling \clearpage, but this way will sacrifice the benefit of latex auto paging.
Is there any other method to update the counter page wherever I want it?
Thank you in advance.
Yuko
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Re: Instead of invoking \clearpage, how to update \thepage s
Instead of invoking \clearpage, how to update \thepage soon?
Code: Select all
\documentclass[a4paper,twoside,11pt,final]{book}
\usepackage[margin=3cm]{geometry}
\usepackage{lipsum,multido}
\newcommand{\tablefactory}
{
\begin{table}
\centering
\begin{tabular}{|c|}\hline
\Huge\thepage \\\hline
\end{tabular}
\caption{Compare it with the page number. Sometimes they are out of sync.}
\end{table}
}
\begin{document}
\multido{\i=1+1}{20}{
\tablefactory
\lipsum[1]
\tablefactory
}
\end{document}
Instead of invoking \clearpage, how to update \thepage soon?
I've explained a typical workaround for this in some other threads. The idea is to use the \label, \pageref mechanism:
Code: Select all
\documentclass{article}
\usepackage[margin=3cm]{geometry}
\usepackage{lipsum,multido}
\newcounter{mycount}
\newcommand{\tablefactory}{%
\begin{table}
\stepcounter{mycount}
\label{tab:\themycount}
\centering
\begin{tabular}{|c|}\hline
\Huge\pageref{tab:\themycount} \\\hline
\end{tabular}
\caption{Compare it with the page number. It's OK now.}
\end{table}}
\begin{document}
\multido{\i=1+1}{20}{%
\tablefactory
\lipsum[1]
\tablefactory
}
\end{document}
Re: Instead of invoking \clearpage, how to update \thepage s
However calling \thepage is mandatory not only inside the table but also other places.
Yuko
Instead of invoking \clearpage, how to update \thepage soon?
Can't you just apply a variation of my proposed solution?yoyoimut wrote:...However calling \thepage is mandatory not only inside the table but also other places...
Instead of invoking \clearpage, how to update \thepage soon?
gmedina wrote:
Can't you just apply a variation of my proposed solution?
Because I don't need labeling so the \pageref is irrelevant in my situation.
Thank you.
Re: Instead of invoking \clearpage, how to update \thepage s
Instead of invoking \clearpage, how to update \thepage soon?
daleif wrote:What is the need for \thepage inside the table anyways?
for the sake of example.
Instead of invoking \clearpage, how to update \thepage soon?
You don't need it, but you might use it to solve your problem, so it doesn't seem to be irrelevant.yoyoimut wrote:...Because I don't need labeling so the \pageref is irrelevant in my situation...