11

NOTE : this problem is closely related to the one here, but I can't seem to adapt it to my situation, since I don't know where the names of these characters (e.g.,\textvisiblespace, \textcompwordmark or \textellipsis) are obtained! I don't know LaTeX very well, and need a bit of help understanding!


I was trying to copy-paste the output of the systemctl status command (of Linux) to minted. Now, normally while all output is displayed properly, for the following output I get an error:

\begin{minted}{console}
# systemctl status httpd -l
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2017-12-16 09:31:03 IST; 3s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 5831 (httpd)
Status: "Processing requests..."
CGroup: /system.slice/httpd.service
├─5831 /usr/sbin/httpd -DFOREGROUND
├─5840 /usr/sbin/httpd -DFOREGROUND
├─5842 /usr/sbin/httpd -DFOREGROUND
├─5843 /usr/sbin/httpd -DFOREGROUND
├─5844 /usr/sbin/httpd -DFOREGROUND
└─5845 /usr/sbin/httpd -DFOREGROUND

Dec 16 09:31:01 vmPrime.somuVMnet.local systemd[1]: Starting The Apache HTTP Server...
Dec 16 09:31:03 vmPrime.somuVMnet.local systemd[1]: Started The Apache HTTP Server.
\end{minted}

My research into this problem has led me to believe, that this problem might occur due to the fact that the characters , and do not have any output mapped to them. However, I can't find a way to get rid of this error. The error I get is of the format:

Package inputenc Error: Unicode char ● (U+25CF)(inputenc) not set up for use with LaTeX. ...d.service \PYGZhy{} The Apache HTTP Server}

The obvious solution would be to remove these characters from the latex file, however, I want the output to be just as seen on the termial. Is there any way I can make LaTeX print these characters inside the output of minted?

Basically how do I get rid of these errors, without getting rid of the characters?


The complete error dump:

line 3: Package inputenc Error: Unicode char ● (U+25CF)(inputenc) not set up for use with LaTeX. ...d.service \PYGZhy{} The Apache HTTP Server}

line 3: Package inputenc Error: Unicode char ● (U+25CF)(inputenc) not set up for use with LaTeX. ...d.service \PYGZhy{} The Apache HTTP Server}

line 11: Package inputenc Error: Unicode char ├ (U+251C)(inputenc) not set up for use with LaTeX. ...5831 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 11: Package inputenc Error: Unicode char ─ (U+2500)(inputenc) not set up for use with LaTeX. ...5831 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 11: Package inputenc Error: Unicode char ├ (U+251C)(inputenc) not set up for use with LaTeX. ...5831 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 11: Package inputenc Error: Unicode char ─ (U+2500)(inputenc) not set up for use with LaTeX. ...5831 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 12: Package inputenc Error: Unicode char ├ (U+251C)(inputenc) not set up for use with LaTeX. ...5840 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 12: Package inputenc Error: Unicode char ─ (U+2500)(inputenc) not set up for use with LaTeX. ...5840 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 12: Package inputenc Error: Unicode char ├ (U+251C)(inputenc) not set up for use with LaTeX. ...5840 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 12: Package inputenc Error: Unicode char ─ (U+2500)(inputenc) not set up for use with LaTeX. ...5840 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 13: Package inputenc Error: Unicode char ├ (U+251C)(inputenc) not set up for use with LaTeX. ...5842 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 13: Package inputenc Error: Unicode char ─ (U+2500)(inputenc) not set up for use with LaTeX. ...5842 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 13: Package inputenc Error: Unicode char ├ (U+251C)(inputenc) not set up for use with LaTeX. ...5842 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 13: Package inputenc Error: Unicode char ─ (U+2500)(inputenc) not set up for use with LaTeX. ...5842 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 14: Package inputenc Error: Unicode char ├ (U+251C)(inputenc) not set up for use with LaTeX. ...5843 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 14: Package inputenc Error: Unicode char ─ (U+2500)(inputenc) not set up for use with LaTeX. ...5843 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 14: Package inputenc Error: Unicode char ├ (U+251C)(inputenc) not set up for use with LaTeX. ...5843 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 14: Package inputenc Error: Unicode char ─ (U+2500)(inputenc) not set up for use with LaTeX. ...5843 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 15: Package inputenc Error: Unicode char ├ (U+251C)(inputenc) not set up for use with LaTeX. ...5844 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 15: Package inputenc Error: Unicode char ─ (U+2500)(inputenc) not set up for use with LaTeX. ...5844 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 15: Package inputenc Error: Unicode char ├ (U+251C)(inputenc) not set up for use with LaTeX. ...5844 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 15: Package inputenc Error: Unicode char ─ (U+2500)(inputenc) not set up for use with LaTeX. ...5844 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 16: Package inputenc Error: Unicode char └ (U+2514)(inputenc) not set up for use with LaTeX. ...5845 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 16: Package inputenc Error: Unicode char ─ (U+2500)(inputenc) not set up for use with LaTeX. ...5845 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 16: Package inputenc Error: Unicode char └ (U+2514)(inputenc) not set up for use with LaTeX. ...5845 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

line 16: Package inputenc Error: Unicode char ─ (U+2500)(inputenc) not set up for use with LaTeX. ...5845 /usr/sbin/httpd \PYGZhy{}DFOREGROUND}

: Over-specification in `h'-direction.

: Over-specification in `v'-direction.

line 12: Overfull \hbox (38.24045pt too wide) in paragraph


My preamble consists of:

\documentclass{report}
\usepackage[utf8]{inputenc}

%   Changing document font to Helvetica.
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault} 
\usepackage[T1]{fontenc}

%   Changing Margins and other formatting
\usepackage{geometry}
\geometry{
    a4paper,
    total={170mm,257mm},
    left=1.5in,
    top=1in,
    right=1.5in,
    bottom=1in
}
\setlength{\parskip}{1em}

%   Source Code Highlighting
\usepackage{minted}
%   For Console
\setminted[console]{
frame=lines,
framesep=2mm,
baselinestretch=1.2,
fontsize=\footnotesize,
linenos,
breaklines
}
%   For Shell Scripts
\setminted[bash]{
    frame=lines,
    framesep=2mm,
    baselinestretch=1.2,
    fontsize=\footnotesize,
    linenos,
    breaklines
}

%   Pretty Tables
\usepackage{booktabs}
\usepackage{array, multirow}

%   Custom column for tables
\newcolumntype{P}[1]{ >{\centering\arraybackslash} m{#1\linewidth} }
\newcolumntype{M}[1]{m{#1\linewidth}}

%   Images Support
\usepackage{graphicx}

%   Support for spaces in file names
\usepackage[space]{grffile}

EDIT

I tried adding this to the preamble (as shown in that related answer):

%   SUPPORT FOR WEIRD CHARACTERS
\DeclareUnicodeCharacter{25CF}{\lgblkcircle}

But it just game me an error:

Undefined control sequence. ...d.service \PYGZhy{} The Apache HTTP Server}

in the pygtex file:

\PYG{g+go}{ ● httpd.service \PYGZhy{} The Apache HTTP Server}
2

3 Answers 3

14

You can declare these characters. For example, like this:

\DeclareUnicodeCharacter{25CF}{$\bullet$}
\DeclareUnicodeCharacter{251C}{\mbox{\kern.23em
  \vrule height2.2exdepth1exwidth.4pt\vrule height2.2ptdepth-1.8ptwidth.23em}}
\DeclareUnicodeCharacter{2500}{\mbox{\vrule height2.2ptdepth-1.8ptwidth.5em}}
\DeclareUnicodeCharacter{2514}{\mbox{\kern.23em
  \vrule height2.2exdepth-1.8ptwidth.4pt\vrule height2.2ptdepth-1.8ptwidth.23em}}
1
  • 1
    \DeclareUnicodeCharacter{25CF}{$\bullet$} solved printing the character problem. Next, the box drawing characters needed to be printed. This I did using: \usepackage{pmboxdraw}. Overall, this has been the simplest no-fuss solution. Nevertheless, thanks everybody for all your help. This community is truly amazing! Dec 16, 2017 at 15:48
6

I was trying to copy-paste the output of the systemctl status command (of Linux) to minted.

When dealing with input that contains more than just one or two unicode-encoded characters, it's a really good idea to switch to a TeX engine -- LuaTeX and XeTeX come to mind -- which can handle such characters natively. (Hint: pdfTeX does not.)

The following solution shows how this may be done in LuaLaTeX, by using the fontspec package. [Note that I've simplified your preamble considerably as your question isn't so much about how to use the minted package as it is about how to display code with utf8-encoded characters.] As long as you choose a competent monospaced font, the characters , , , , etc will now get typeset without a fuss.

enter image description here

% !TEX TS-program = lualatex
\documentclass{report}
\usepackage[a4paper,margin=2cm]{geometry}

\usepackage{fontspec}
\setmonofont{consolas} % choose a suitable monospaced font

\begin{document}

\begin{verbatim}
# systemctl status httpd -l
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2017-12-16 09:31:03 IST; 3s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 5831 (httpd)
Status: "Processing requests..."
CGroup: /system.slice/httpd.service
├─5831 /usr/sbin/httpd -DFOREGROUND
├─5840 /usr/sbin/httpd -DFOREGROUND
├─5842 /usr/sbin/httpd -DFOREGROUND
├─5843 /usr/sbin/httpd -DFOREGROUND
├─5844 /usr/sbin/httpd -DFOREGROUND
└─5845 /usr/sbin/httpd -DFOREGROUND

Dec 16 09:31:01 vmPrime.somuVMnet.local systemd[1]: Starting The Apache HTTP Server...
Dec 16 09:31:03 vmPrime.somuVMnet.local systemd[1]: Started The Apache HTTP Server.
\end{verbatim}

\end{document}
4

You can use \textbullet for ● (U+25CF BLACK CIRCLE) or \ding{108} (the latter requires the pifont package). For the box drawing symbols there's pmboxdraw.

I also reformatted your preamble to separate package loading from settings. For geometry, you are overspecifying: a height of 257mm plus top and bottom margin of 1in don't fit A4 paper. I only left the total and added heightrounded, which is recommended in order to accommodate an integer number of lines.

\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

% Packages
\usepackage[scaled]{helvet}
\usepackage{geometry}
\usepackage{minted}

\usepackage{booktabs}
\usepackage{array}
\usepackage{multirow}
\usepackage{pmboxdraw} % for box drawings
\usepackage{pifont} % for the black circle
\usepackage{graphicx}
\usepackage[space]{grffile}

% Settings
\renewcommand\familydefault{\sfdefault} % sans serif by default

\geometry{
  a4paper,
  total={170mm,257mm},
  heightrounded,
}
\setlength{\parskip}{1em}

%   For Console
\setminted[console]{
  frame=lines,
  framesep=2mm,
  baselinestretch=1.2,
  fontsize=\footnotesize,
  linenos,
  breaklines
}
%   For Shell Scripts
\setminted[bash]{
  frame=lines,
  framesep=2mm,
  baselinestretch=1.2,
  fontsize=\footnotesize,
  linenos,
  breaklines
}

%   Custom column for tables
\newcolumntype{P}[1]{ >{\centering\arraybackslash} m{#1\linewidth} }
\newcolumntype{M}[1]{m{#1\linewidth}}

% last minute adjustment 
\DeclareUnicodeCharacter{25CF}{\resizebox{0.5em}{!}{\ding{108}}}

\begin{document}

\begin{minted}{console}
# systemctl status httpd -l
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2017-12-16 09:31:03 IST; 3s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 5831 (httpd)
Status: "Processing requests..."
CGroup: /system.slice/httpd.service
├─5831 /usr/sbin/httpd -DFOREGROUND
├─5840 /usr/sbin/httpd -DFOREGROUND
├─5842 /usr/sbin/httpd -DFOREGROUND
├─5843 /usr/sbin/httpd -DFOREGROUND
├─5844 /usr/sbin/httpd -DFOREGROUND
└─5845 /usr/sbin/httpd -DFOREGROUND

Dec 16 09:31:01 vmPrime.somuVMnet.local systemd[1]: Starting The Apache HTTP Server...
Dec 16 09:31:03 vmPrime.somuVMnet.local systemd[1]: Started The Apache HTTP Server.
\end{minted}

\end{document}

Instead of \resizebox{0.5em}{!}{\ding{108}} you can use \textbullet; the output is essentially the same.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .