Instead of pure LaTeX, I suggest mix LaTeX with R code in a "R-noweb" file (plain text file but with the .Rnw
extension):
\documentclass{article}
\begin{document}
<<results='hide'>>=
Italy <- 800000 # km of road by Wikipedia
SRS <- 14839.9 # km the paths of the project
SRSpercent <- SRS / Italy * 100
@
The value of SRSpercent is \Sexpr{round(SRSpercent,2)} \%.
\end{document}
Compiled with:
Rscript -e "library(knitr); knit('my_sweave_file.Rnw')"
pdflatex my_sweave_file.tex
Or just "compile PDF" buttom from Rstudio, the result should be:
The value of SRSpercent is 1.85 %.
The may be not-so-clear advantages of these approach is that you can (a) use the variables for much more that simple arithmetic, (b) any R result (as verbatim text or figures) could be inserted automatically in the LaTeX document but moreover (c) R can produce some results in LaTeX format (chunks of LaTeX text, tables) and therefore indistinguishable of the LaTeX text.
Just a more complex example to explain what I mean:
\documentclass[a5paper,landscape,twocolumn]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{booktabs}
\usepackage[colorlinks]{hyperref}
\begin{document}
<<sourcedata,results="hide",echo=F,message=F>>=
library(Hmisc)
library(xtable)
Italy <- 800000
label(Italy) <- "km of the Italian road network"
SRS <- 14839.9
label(SRS) <- "km of paved roads by the SRS project"
vkm <- c(Italy,SRS)
km <- data.frame(Italy,SRS)
rownames(km) <- c("km")
@
\section{Source data}
Statistical data used in this report are only two measures in km of
roads from Italy and the SRS project:
\begin{itemize}
\item
<<results="asis", echo=FALSE>>=
cat(vkm, sep="\n\\item ")
@
\end{itemize}
Is not too much, but it is only a example. Confused with so many data?
See table \ref{xtable}.
<<showdata,warning=F,results="asis",echo=F,comment="">>=
print(xtable(km, digits=1,
caption="Data used in this report.",label="xtable"),
booktabs=TRUE,caption.placement="top")
@
\section{Conclusions}
<<percentage,echo=F>>=
SRSpercent <- SRS / Italy * 100
label(SRSpercent) <- "SRS contribution"
@
In the \Sexpr{Italy}~\Sexpr{label(Italy)},
the roughly \Sexpr{options(scipen=6)}\Sexpr{round(SRS,0)}
\Sexpr{label(SRS)} mean a \Sexpr{label(SRSpercent)} of
\Sexpr{round(SRSpercent,2)}\%. Not enough clear? See figure
\ref{fig:figure} for a better understanding.
\newpage
<<figure,echo=F,fig.cap="Extension of Italian network road in kilometers",fig.pos="h", fig.height=6>>=
pie(c(Italy-SRS,SRS),labels=c("Others","SRS"), col=c("green","red"))
@
\end{document}
And finally, not showed above (d) R can load data of external files, if you take care of all things that could change in a manuscript when source data has changed, and your replace these by R-generated values/text/tables/figures, you can update entirely a report without touch the LateX template, only compiling again, with the security of zero mistakes in the updates.