TeX - LaTeX Asked on March 28, 2021
The following MWE throws the error
Undefined control sequence. GenericError …
#4 errhelp @err@ … l.9 immediatewritefich@sol {section{Test}}
?
What’s the problem?
documentclass{article}
makeatletter
newwrite fich@sol
defnameFile{example.sol}
AtBeginDocument{ immediateopenout fich@sol nameFile}
AtEndDocument{ immediatecloseout fich@sol}
immediatewritefich@sol {section{Test}}
makeatother
begin{document}
Test
end{document}
You have to prevent expansion while you write to the file, you can do so by prefixing section
with string
or noexpand
(the difference is small, but with string
you'll get no space after section
in the output, while with noexpand
you'll get section {Test}
):
documentclass{article}
makeatletter
newwrite fich@sol
defnameFile{example.sol}
AtBeginDocument{ immediateopenout fich@sol nameFile}
AtEndDocument{ immediatecloseout fich@sol}
begin{document}
Test
immediatewritefich@sol {stringsection{Test}}
makeatother
end{document}
Correct answer by Skillmon on March 28, 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