3

I got a file 'month.tex' containing only an integer. I want to set a counter to this integer and tried

\newcounter{billmonth}
\setcounter{billmonth}{\input{month.tex}}

This isn't working as the compiler sais

<to be read again> 
\let 
l.42 \setcounter{billmonth}{\input{month.tex}}

Does anybode have an idea how to deal with this? Thanks!

Why do I have a file containing only this integer? I use a bash script for compiling where you can pass an argument. This argument needs to find its way inside of my latex document and it was the best way i could think of.

6

The readarray package can help, with its \readdef{<filename>}\macro syntax.

\documentclass{article}
\usepackage{filecontents}% this is only to show that it works
\begin{filecontents*}{monthfile}
 3
\end{filecontents*}
\usepackage{readarray}
\readdef{monthfile}\thereadmonth
\newcounter{billmonth}
\setcounter{billmonth}{\thereadmonth}
\begin{document}
\thebillmonth
\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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