How to solve the `Package inputenc Error: Unicode char not set up for use with LaTeX` problem?
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}}
I was trying to copy-paste the output of the
systemctl
status command (of Linux) tominted
.
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.
% !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}
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.