Hi all,
Thanks for the discussion here. I was experiencing a problem with \pageref{LastPage}.
With my current list of packages, just loading lastpage after minitoc didn't work for me: when Latex would encounter my definitions like \newcommand{\mycommand} (which otherwise passed), including lastpage after minitoc would result with:
Code: Select all
! LaTeX Error: Command \mycommand already defined.
Or name \end... illegal, see p.192 of the manual.
Commenting lastpage, and using instead the code from phi in post #pr14259 with \usepackage{scrlfile} and \BeforeClosingMainAux passes during the first time I compile; but the second time crashes with:
Code: Select all
Runaway argument?
{\@secondoffive }\fi
! Paragraph ended before \Hy@setref@link was complete.
... In the end, I somehow stumbled upon
Google Translate: lastpage.styとhyperref.styの競合について; from where I found the page
[qa:46490] Re: lastpage.styとhyperref.styの競合について with code that worked for me with hyperlinks - I just had to modify the counters so that they modify by 1 and not by 2 in my case; the MWE example being:
Code: Select all
\documentclass{article}
\makeatletter
\def\lastpage@putlabel{%
\addtocounter{page}{-1}%
\if@filesw
\begingroup
\let\@number\@firstofone
\ifHy@pageanchor
\ifHy@hypertexnames
\ifHy@plainpages
\def\Hy@temp{\arabic{page}}%
\else
\pdfstringdef\Hy@temp{\thepage}%
\fi
\else
\def\Hy@temp{\the\Hy@pagecounter}%
\fi
\fi
\immediate\write\@auxout{%
\string\newlabel
{LastPage}{{}{\thepage}{}{%
\ifHy@pageanchor page.\Hy@temp\fi}{}}%
}%
\endgroup
\fi
\addtocounter{page}{1}%
}%
\AtEndDocument{%
\message{AED: lastpage setting LastPage}%
\clearpage\lastpage@putlabel}%
\makeatother
\usepackage{hyperref}
\begin{document}
test\clearpage
test. \pageref{LastPage}
\end{document}
which now compiles fine, also with hyperlink.