Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Emacs org-mode, Latex export of literal string containing "\__" giving problem

I am trying to export a literal string from Emacs Org-mode to Latex for subsequent export to PDF. The literal string is:

str1\__str2

I have tried the following input in the Org file:

\verb+str1\__str2+

This produces the following code in the .tex file:

\verb+str1\hspace{3ex}str2+

I expected the following code in the .tex file:

\verb+str1\__str2+

I have also tried the following in the Org file:

\begin{verbatim}
str1\__str2
\end{verbatim}

This produces the following code in .tex file:

\begin{verbatim}
str1\hspace{3ex}str2
\end{verbatim}

Including the following option in the Org file has no effect on the output:

#+OPTIONS:     ^:{}
like image 881
Sharad Avatar asked May 10 '11 02:05

Sharad


2 Answers

If you don't mind the verbatim block, which you indicated above you're ok with, then this:

#+BEGIN_EXAMPLE
   str1\__str2
#+END_EXAMPLE

Produces this:

\begin{verbatim}
str1\__str2
\end{verbatim}
like image 98
Wes Hardaker Avatar answered Sep 25 '22 19:09

Wes Hardaker


You can use org-entities-user to create your own entities with different translations on export.

Setting it to e.g. (("textbackslash" "\\textbackslash" nil "\\" "\\" "\\" "\\")) will translate \textbackslash to \textbackslash on LaTeX output and to \ for all other outputs.

like image 44
pft Avatar answered Sep 25 '22 19:09

pft