I want to write a backslash character to a text file using LaTeX.
The first line of code below declares a variable 'file' which describes the file 'myfile.out'. The second line opens the file and the third one tries do write a backslash '\' to the file.
\documentclass{article} \begin{document} \newwrite\file% \immediate\openout\file=myfile.out% \immediate\write\file{\}% \end{document}
The third line does not work because LaTeX get confused with the backslash, anyone knows how can I make it work? I tried a lot of things including \textbackslash, $\backslash$ \char
``\` etc and nothing seems to work.
Thanks a lot
The \\ is context-dependent macro in LaTeX. It means that it is internally redefined in various situations and various LaTeX environments. By default it is \hfil\break and this can be used inside the paragraphs in order to "destroy" the normal paragraph formatting.
You may be wondering how to insert symbols in LaTeX. It is possible to add certain symbols in-text while others require LaTeX's math mode to be activated. ”, you can use the command \star in your code.
How to Insert a Tilde Symbol (~) in LaTeX. You can write a tilde (sometimes called “twiddle”) in a LaTeX document by using \(\sim \) or $\sim$ (sim stands for similar). As an alternative you can use \texttildelow from thetextcomp package.
Sound like you want a backslash in text mode; since \backslash
does not work, try \textbackslash
.
EDIT: \symbol{92}
should also work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With