4

I've been working on some diagrams for a slide deck using beamer and minted (and buliding the PDF with Xelatex). When using the Unicode box-drawing characters, the vertical bars are not actually "connecting" like the rest of the characters. I thought it was an issue with my font at first (DejaVu Sans), but I've since tried several different monospace fonts with no luck. I've also tried tweaking the baseline options on the minted environment, but with no change (negative numers don't appear to affect it at all). Finally, I tried adding a new Unicode character that would replace the vertical line with a tikz drawing (of a vertical line), but that was a bit of a hack and I could never get it to look quite right where it intersected the normal box drawing characters, and don't want to redefine every character I might ever use).

I'd like to know what's causing this problem. Note that the same thing happens outside of the Minted environment, and if I'm using another class, however, the knowledge that it's in a Beamer/Verbatim environment may affect the solution, so I've included it in the MWE below:

\documentclass[xelatex,aspectratio=169]{beamer}

\usepackage{fontspec,minted}

\setmonofont{Source Code Pro}
% \setmonofont{DejaVu Sans} % Same thing

% Don't display annoying red boxes around errors
\renewcommand{\fcolorbox}[4][]{#4}
\begin{document}

\begin{frame}[fragile]
\begin{minted}{C}
      ╭─────────────────────────────╮
      │                  ╭───╮      │
      │  ╭───╮           │╭─╮│      │
      │  ↑   │           │↑ ││      │
void (*signal(int, void (*fp)(int)))(int);
 ↑    ↑      │      ↑    ↑  ││      │
 │    ╰──────╯      │    ╰──╯│      │
 │                  ╰────────╯      │
 ╰──────────────────────────────────╯
\end{minted}
\end{frame}

\end{document}

which produces (note the gaps in the vertical bars):

broken vertical box drawing characters

  • I assume it's \lineskip glue but when I run this I seem to just get a white frame with just the navigation icons. Odd as minted clearly runs and makes its cache stuff – David Carlisle Dec 26 '15 at 22:41
  • Are you running in write18 mode? Minted will need to call out to Pygments (I think it generates an empty cache file even if it doesn't work). It also requires a couple of passes. – Sam Whited Dec 26 '15 at 22:54
  • had to move your renewcommand over the document begin to get it running – Rico Dec 26 '15 at 22:58
  • How odd, works fine for me either way. Edited the MWE. – Sam Whited Dec 26 '15 at 23:04
  • The reason is that the arrow is much shorter than the bar, see this picture – egreg Dec 26 '15 at 23:29
4

The reason is that the arrow is much shorter than the character U+2502, BOX DRAWINGS LIGHT VERTICAL, as shown in this picture:

enter image description here

The other reason is that \lineskip enters the way.

An acceptable version can be obtained by using an arrow in another font, then scaling it a bit to reflect the dimensions of the box drawing characters.

\documentclass{article}

\usepackage{fontspec,minted,color,graphicx}
\usepackage{newunicodechar}

\setmonofont{Source Code Pro}
\newfontfamily{\Carrows}{TeX Gyre Adventor}
\newunicodechar{↑}{\arrowresize{\Carrows ↑}}
\newcommand{\arrowresize}[1]{%
  \sbox0{\ttfamily │}%
  \setlength{\dimen8}{\dimexpr\ht0+\dp0\relax}%
  \makebox[\wd0]{\raisebox{-.5\dp0}[\ht0][\dp0]{\resizebox{\width}{.8\dimen8}{#1}}}%
}

% Don't display annoying red boxes around errors
\renewcommand{\fcolorbox}[4][]{#4}

\begin{document}

\setlength{\lineskip}{0pt}
\begin{minted}{C}
      ╭─────────────────────────────╮
      │                  ╭───╮      │
      │  ╭───╮           │╭─╮│      │
      │  ↑   │           │↑ ││      │
void (*signal(int, void (*fp)(int)))(int);
 ↑    ↑      │      ↑    ↑  ││      │
 │    ╰──────╯      │    ╰──╯│      │
 │                  ╰────────╯      │
 ╰──────────────────────────────────╯
\end{minted}

\end{document}

Do the assignment to \lineskip only locally.

enter image description here

  • I actually meant just the vertical lines, not the arrows (which I know weren't designed to be part of the box drawing set). I'd actually assumed it was the line skip originally and changed it to no effect, but I must have typo-ed it or set it wrong, because that appears to be working fine. Many thanks! – Sam Whited Dec 27 '15 at 1:29

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.