TeX - LaTeX Asked on August 13, 2021
I’m trying this:
documentclass{article}
usepackage{calc}
newlength{foo}
newcommand{zzz}{input{size.txt}}
setlength{foo}{2in * zzz}
usepackage[paperwidth=foo,paperheight=foo]{geometry}
begin{document}
end{document}
But I’m getting:
! Missing number, treated as zero.
<to be read again>
let
l.5 setlength{foo}{2in * zzz}
How to fix this?
The LaTeX input
command is not expandable: this is partly due to the fact it does 'safe' check for the existence of a file, and partly due to supporting both TeX primitive (input <file>
) and LaTeX (input{<file>}
) syntaxes. This means that if you want to work by expansion, as you do here, you need to use the primitive
begin{filecontents*}[overwrite]{size.txt}
5%
end{filecontents*}
documentclass{article}
usepackage{calc}
newlength{foo}
makeatletter
letprimitiveinput@@input
makeatother
newcommand{zzz}{primitiveinput size.txt }
setlength{foo}{2in * zzz}
usepackage[paperwidth=foo,paperheight=foo]{geometry}
begin{document}
end{document}
You'll need to make sure your input file doesn't have a par
token in it: I've added an example using a comment char.
Correct answer by Joseph Wright on August 13, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP