# Render utf8 characters in pdf

I have a *.tex document encoded in UTF-8 which includes these characters:

⎡6  1⎤
⎢    ⎥
⎣5  3⎦


I'm having troubles reproducing such characters (apart from the numbers of course). I tried the following combinations all failing for different reasons. I'm on MacOS 10.6, if that matters:

• Compile with pdflatex or xelatex with or without \usepackage{fontspec}: The pdf output displays the matrix above as "6 1 5 3" (all in one line, and only numbers and blanks).
• Use \usepackage[utf8x]{inputenc} and compile with pdflatex results in the error:

Package ucs Error: Unknown Unicode character 9121 = U+23A1,

Any idea how to render the matrix above? Also, these are not the only "unusual" characters I might come across later so I'd like a general solution if possible.

• Wouldn't you prefer to typeset that as math, without the need of crafting glyphs? – Johannes_B Mar 15 '15 at 10:47
• @Johannes_B You mean in equation env as \left[\begin{matrix}6 & 1\\5 & 3\end{matrix}\right]? Sure, but I'm copying this output from a terminal window (from python SymPy to be precise) and I'd like to be able to paste it in the tex document as is. – dariober Mar 15 '15 at 10:54
• How are you handling linebreaks? – Johannes_B Mar 15 '15 at 10:57
• The tex file has \n (newline, line feed) as EOL character, I'm writing it in Komodo Edit. – dariober Mar 15 '15 at 11:01

You can try pmboxdraw together with newunicodechar:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pmboxdraw,newunicodechar,fancyvrb,graphicx}

\newunicodechar{⎡}{\raisebox{1ex}{\makebox[.5em]{\textSFi}}}
\newunicodechar{⎤}{\raisebox{1ex}{\makebox[.5em]{\textSFiii}}}
\newunicodechar{│}{\makebox[.5em]{\textSFxi}}
\newunicodechar{⎣}{\raisebox{-1ex}{\makebox[.5em]{\textSFii}}}
\newunicodechar{⎦}{\raisebox{-1ex}{\makebox[.5em]{\textSFiv}}}

\begin{document}
\begin{Verbatim}
⎡6 1⎤
│   │
⎣5 3⎦
\end{Verbatim}
\end{document}


• Thanks for your answer. But as I understand it each character has to be "registered" with \newunicodechar. The example I showed has just some of unicode chars I came across so I was hoping for a simpler and more general solution like \usepackage{enable-all-UTF8-chars}. – dariober Mar 15 '15 at 16:27
• @dariober That's simply hopeless. – egreg Mar 15 '15 at 17:01