1

When I copy-paste curly brackets (aka braces) from \texttt{} mode, they are interpreted as f and g. What can I do to get proper curly brackets? I tried to use \string but this seems not to allow to be split across multple line


Here is my minimal working example

\documentclass{article}
\usepackage{empheq}
\newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}}

\begin{document}

Compiles but gives "f g"-problem:
\begin{empheq}[box=\fbox]{align*}
&\texttt{\{}\\
&\texttt{something}\\
&\texttt{\}} 
\end{empheq}

Compiles and gives proper curly brackets, but I need three lines not one:
\begin{empheq}[box=\fbox]{align*}
\texttt{\string{ something \string}}
\end{empheq}

\iffalse
Does not compile:
\begin{empheq}[box=\fbox]{align*}
\texttt{\string{ \\
 something \\
 \string}}
\end{empheq}
\fi

\end{document} 
  • This is what I get when I compile your code... no f g-problem. – Werner Jul 11 '17 at 19:48
  • The same as I do. And when I copy and paste from the generated pdf, they are correct. – gusbrs Jul 11 '17 at 19:48
  • 3
    Try adding \usepackage[T1]{fontenc}, but I can't reproduce the issue. What TeX distribution and operating system are you running? – egreg Jul 11 '17 at 19:50
  • 1
    you want \usepackage[T1]{fontenc} so that \{ uses the ascii { slot – David Carlisle Jul 11 '17 at 19:51
3

I can't reproduce the issue; on the other hand, if you want to get the braces in the monospaced font you can either load

\usepackage[T1]{fontenc}

or input them as

\texttt{\symbol{`\{}}

and

\texttt{\symbol{`\}}}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.