Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the following:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{fancyhdr}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{expl3}
\usepackage{pst-eucl}
\usepackage{hyperref}


\ExplSyntaxOn
  \cs_new_eq:NN \calculate \fp_eval:n
\ExplSyntaxOff


\def\hoejde{\calculate{3*\figurnummer}}
\def\bredde{\calculate{2*\figurnummer}}
\def\areal{\calculate{3*\figurnummer^2}}
\def\faktorA{\calculate{\hoejde+1}}
\def\faktorB{\calculate{\bredde+1}}
\def\faktorC{\calculate{\hoejde-1}}
\def\faktorD{\calculate{\figurnummer-1}}
\def\skalering{\calculate{1.9/\figurnummer}}

\def\betegn#1#2#3{%
  \rput(!#1 4 div \figurnummer mul #2 4 div \figurnummer mul){\small{$#3$}}
}

\def\figur#1{%
\begin{figure}[htbp]
\def\figurnummer{#1 }
\centering
\psset{unit=\skalering}
\begin{subfigure}{0.56\textwidth}
\centering
  \begin{pspicture}(0,0)(\bredde,\hoejde)
    \pnodes{P}(\figurnummer,0)(0,\bredde)(\figurnummer,\hoejde)(\bredde,\bredde)
    \betegn{3}{7}{A}
    \betegn{3}{9}{B}
    \betegn{5}{9}{C}
    \betegn{5}{7}{D}
  {\psset{linestyle=dashed,linecolor=blue}
    \multido{\iA=0+1}{\faktorA}{\psline(0,\iA)(\bredde,\iA)}
    \multido{\iB=0+1}{\faktorB}{\psline(\iB,0)(\iB,\hoejde)}}
   \psset{linewidth=1pt}
    \psline(P0)(P2)
    \psline(P1)(P3)
    \pspolygon[linejoin=2,linecolor=red](P0)(P1)(P2)(P3)
  \end{pspicture}
 \subcaption{Before.}
\end{subfigure}
\begin{subfigure}{0.40\textwidth}
\centering
  \begin{pspicture}(0,0)(\figurnummer,\hoejde)
    \pnodes{P}(0,0)(0,\bredde)(0,\hoejde)(\figurnummer,\hoejde)(\figurnummer,\bredde)(\figurnummer,0)
    \betegn{3}{7}{A}
    \betegn{3}{9}{B}
    \betegn{1}{11}{C}
    \betegn{1}{1}{D}
  {\psset{linestyle=dashed,linecolor=blue}
    \multido{\iC=1+1}{\faktorC}{\psline(0,\iC)(\figurnummer,\iC)}
    \multido{\iD=1+1}{\faktorD}{\psline(\iD,0)(\iD,\hoejde)}}
   \psset{linewidth=1pt}
    \psline(P1)(P4)
    \psframe(P0)(P3)
    \psline[linejoin=1,linecolor=red](P5)(P1)(P3)
  \end{pspicture}
 \subcaption{After.}
\end{subfigure}
\caption{Figure number~$\figurnummer$ with area~$A_{\figurnummer} = \areal$.}
\end{figure}
\vspace{6ex}
}

\cfoot{\thepage}


\begin{document}

\pagenumbering{roman}
\pagestyle{plain}
\tableofcontents
\newpage

\pagenumbering{arabic}

Test.
\newpage

\section{Appendix}
\label{appendix}
\def\sider{3}
See the figures on \autopageref{appendix}--[the value of $\texttt{\textbackslash pageref\{appendix\}} + \texttt{\textbackslash sider} - 1$].

% Figurerne.
\multido{\iE=1+2,\iF=1+1}{\sider}{%
  \multido{\iG=\iE+1}{2}{\figur{\iG}}
  \newpage
}

\end{document}

How do I create a counter with the value of

\pageref{appendix} + \sider - 1

? The point is that this value is equal to the page number on the last page.

share|improve this question
    
have you seen How can I add "page # of ##" on my document? –  cmhughes Sep 27 '13 at 17:19

1 Answer 1

up vote 4 down vote accepted

You can use the lastpage package to get the value of the counter for the last page. There is also the pageslts package, which the documentation for lastpage encourages you to use.

With lastpage, you can refer to the value of the last page using the command

\pageref{LastPage}
share|improve this answer
    
I guess it should be \getpagerefnumber{LastPage} (requires \usepackage{refcount}) if it's needed inside \calculate; otherwise a run when the reference is not set will produce loads of errors. –  egreg Sep 27 '13 at 13:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.