From 94fb86a6d1ccef5c3106594615898845b7c97568 Mon Sep 17 00:00:00 2001 From: Joel Dueck <1553115+otherjoel@users.noreply.github.com> Date: Sun, 20 Sep 2020 15:15:23 -0500 Subject: [PATCH] Fix lozenge chars in code listings (fixes #4) --- template.pdf.p | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/template.pdf.p b/template.pdf.p index 0252228..69dd806 100644 --- a/template.pdf.p +++ b/template.pdf.p @@ -69,8 +69,10 @@ \usepackage{textcomp} \usepackage{upquote} - \usepackage{listings} + \usepackage{listingsutf8} \lstset{ + inputencoding=utf8, + extendedchars=true, basicstyle=\scriptsize\ttfamily, columns=flexible, breaklines=true, @@ -88,6 +90,21 @@ % belowcaptionskip=0pt, numberstyle=\scriptsize\color{mygray}\linenumberfont } + +% Add the lozenge to the list of extended characters in the `listings` +% environment. This is a limited workaround for a problem where Unicod +% characters appear out of order in code listings. +% See https://tex.stackexchange.com/q/81674 +% +\begingroup + \catcode0=12 % + \makeatletter + \g@addto@macro\lst@DefEC{% + \lst@CCECUse\lst@ProcessLetter + ◊"◊"% *** add Unicode characters *** + ^^00% end marker + }% +\endgroup % see http://tex.stackexchange.com/questions/11263/how-can-i-remove-listing-from-listings-caption % and http://tex.stackexchange.com/questions/209764/how-can-i-make-the-width-of-the-caption-match-that-of-the-listing