# Help drawing as text a number from a formula (For instance [ 1-\thepage)*70+\i ] )

Googling I found that it is common that \lineno does not work properly around displaymath with the ifacconf.cls template.

I am trying to improve a workaround I found for peer review reference. Specifically THIS ONE.

I would like to print the number result of the following operation $(1-\thepage)*70+\i$ instead of just \i. Any clues?

See the minimal example which prints literally "(1-"$\thepage$")*70+"$\i$

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz,everypage}
\AtBeginDocument{%
\begin{tikzpicture}[remember picture,overlay]
\path (current page.north west) --  (current page.south west) \foreach \i in {1,...,\fakelinenos} { node [pos={(\i-.5)/\fakelinenos}, xshift=\fakelinenoshift, line number style] { $(1-\thepage)*70+\i$} }  ;
\end{tikzpicture}%
}%
}
\tikzset{%
line numbers/.store in=\fakelinenos,
line numbers=70,
line number shift/.store in=\fakelinenoshift,
line number shift=5mm,
line number style/.style={text=gray},
}
\begin{document}
\section{problem (a), page 88}
$y^{\prime\prime}=\frac{1}{x^{5}}y$
Irregular singular point at $x\rightarrow0^{+}$.
Let $y=e^{S_{0}\left(x\right)}$ and the above becomes%
\begin{align*}
y\left(  x\right)   &  =e^{S_{0}\left(  x\right)  }\\
y^{\prime}\left(  x\right)   &  =S_{0}^{\prime}e^{S}\\
y^{\prime\prime} &  =S_{0}^{\prime\prime}e^{S_{0}}+\left(  S_{0}^{\prime
}\right)  ^{2}e^{S_{0}}\\
&  =\left(  S_{0}^{\prime\prime}+\left(S_{0}^{\prime}\right) ^{2}\right)e^{S_{0}}
\end{align*}
Substituting back into $\frac{d^{2}}{dx^{2}}y=x^{-5}y$ gives

Hence
\begin{align*}
S_{1}  & \thicksim-\int\frac{S_{0}^{\prime\prime}}{S_{0}^{\prime}}dx\\
& \thicksim-\ln S_{0}^{\prime}+c
\end{align*}
\end{document}


When you want to calculate a value you cannot just put the formula in the code, as you have seen. There are a few options to do calculations. Without packages you can use \numexpr (see for example How to add, subtract, multiply, and divide in plain TeX?) or with packages you can use the fp package or the xint bundle, but given that you already use tikz you can use \pgfmathparse to perform calculations.

This macro performs the calculation in the argument and stores the result in the macro \pgfmathresult. You can use this macro to print the computed value. The calculation is floating point, so the result will have .0 as a suffix for integers. You can use \pgfmathprintnumber to round the values.

For your calculation I expect you want continuous numbers for each page, i.e., page 1 has 1-70, page 2 has 71-140, etc. To accomplish this I have modified your calculation to be \thepage-1 instead of 1-\thepage. I have manually set the page number to 88 to show the result of the calculation.

MWE:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz,everypage}
\AtBeginDocument{%
\begin{tikzpicture}[remember picture,overlay]
\path (current page.north west) --  (current page.south west) \foreach \i in {1,...,\fakelinenos} { node [pos={(\i-.5)/\fakelinenos}, xshift=\fakelinenoshift, line number style] { \pgfmathparse{(\thepage-1)*70+\i}\pgfmathprintnumber{\pgfmathresult}} }  ;
\end{tikzpicture}%
}%
}
\tikzset{%
line numbers/.store in=\fakelinenos,
line numbers=70,
line number shift/.store in=\fakelinenoshift,
line number shift=5mm,
line number style/.style={text=gray},
}
\setcounter{page}{88} % set the page number manually
\begin{document}
\section{problem (a), page 88}
$y^{\prime\prime}=\frac{1}{x^{5}}y$
Irregular singular point at $x\rightarrow0^{+}$.
Let $y=e^{S_{0}\left(x\right)}$ and the above becomes%
\begin{align*}
y\left(  x\right)   &  =e^{S_{0}\left(  x\right)  }\\
y^{\prime}\left(  x\right)   &  =S_{0}^{\prime}e^{S}\\
y^{\prime\prime} &  =S_{0}^{\prime\prime}e^{S_{0}}+\left(  S_{0}^{\prime
}\right)  ^{2}e^{S_{0}}\\
&  =\left(  S_{0}^{\prime\prime}+\left(S_{0}^{\prime}\right) ^{2}\right)e^{S_{0}}
\end{align*}
Substituting back into $\frac{d^{2}}{dx^{2}}y=x^{-5}y$ gives

Hence
\begin{align*}
S_{1}  & \thicksim-\int\frac{S_{0}^{\prime\prime}}{S_{0}^{\prime}}dx\\
& \thicksim-\ln S_{0}^{\prime}+c
\end{align*}
\end{document}


Result:

• Thanks, that, and the documentation for \pgfmathparse solved it. I ended up using \pgfmathparse{int((\thepage-1)*70+\i)} \pgfmathresult – loBandolerPi Jul 23 at 14:39