4

I have got some special characters I wish Latex to treat 'as is', which I understood Verbatim is for (I'm new to Latex).

\begin{verbatim}
        ┌─┐
q_0: |0>┤M├
        └╥┘
 c_0: 0 ═╩═
\end{verbatim}

However the PDF result shows up as ???

        ???
q_0: |0>?M?
        ???
 c_0: 0 ???

How can I show/print my special characters properly?

Rien
  • 195

1 Answers1

10

One possibility is with the pmboxdraw package:

\documentclass[]{article}
\usepackage{pmboxdraw}
\begin{document}

\begin{verbatim}
        ┌─┐
q_0: |0>┤M├
        └╥┘
 c_0: 0 ═╩═
\end{verbatim}

\end{document}

enter image description here

Another with lualatex and a suitable typewriter font:

\documentclass[]{article}
\usepackage{fontspec}
\setmonofont{DejaVuSansMono}
\begin{document}

\begin{verbatim}
        ┌─┐
q_0: |0>┤M├
        └╥┘
 c_0: 0 ═╩═
\end{verbatim}

\end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • The first solution works great, though only when i put it in a new empty latex document. not my current one, trying to figure out why its not doing anything (compiles just fine) – Rien Nov 19 '19 at 22:39
  • Can't seem to get it working in my current document, would you have a clue why? – Rien Nov 19 '19 at 22:56
  • 3
    minimize your document until you find the conflicting package. – Ulrike Fischer Nov 19 '19 at 23:03
  • Even when i remove everything in the document, and copy exactly your answer.. it still doesnt work. Even though it does when I make a new document. I tried restarting Texteditor. – Rien Nov 19 '19 at 23:25
  • 4
    Are you sure that your document is utf8 encoded? – Ulrike Fischer Nov 19 '19 at 23:32
  • I already had the following line \usepackage[utf8]{inputenc} which didnt work. but when i went to edit > encoding > change to (utf8) which was alreayd at the top on position 1, it was fixed. Thanks a lot! working great now – Rien Nov 19 '19 at 23:45