Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print out a backslash in LaTeX

Tags:

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

like image 204
Giovanni Funchal Avatar asked Jan 18 '10 15:01

Giovanni Funchal


People also ask

How do you make a double backslash in LaTeX?

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.

How do I type a symbol in LaTeX?

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 do I show a tilde in LaTeX?

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.


1 Answers

Sound like you want a backslash in text mode; since \backslash does not work, try \textbackslash.

EDIT: \symbol{92} should also work.

like image 112
Martijn Avatar answered Sep 18 '22 13:09

Martijn