8

I have switched to XeLaTex several months ago, and tried today to include a Cisco IOS code with the following parameters (How to insert code from a Router or a Switch), as I was doing before using XeLaTex:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{booktabs}
\usepackage{etoolbox}
\usepackage[most]{tcolorbox}

\newtcblisting{cisco}[1][]{size=fbox, listing only, listing options={style=tcblatex,basicstyle=\ttfamily\scriptsize,tabsize=2,language=sh},#1}

\begin{document}

\begin{cisco}[title=Example of cisco command]
master#show ip cef 10.200.254.4
10.200.254.4/32, version 44, epoch 0, cached adjacency 10.200.200.2
0 packets, 0 bytes
    tag information set, all rewrites owned
    local tag: 20
    fast tag rewrite with Eth0/0/0, 10.200.200.2, tag imposed {18} via 10.200.200.2, Ethernet0/0/0, 0 dependencies
    next hop 10.200.200.2, Ethernet0/0/0
    valid cached adjacency
    tag rewrite with Et0/0/0, 10.200.200.2, tags imposed {18}
\end{cisco}

\end{document}

This produce the same output, which is exactly what I want. However, I have this error:

Package inputenc Error: inputenc is not designed for xetex or luatex \end{cisco}

What can I do to still use XeLaTex and include Cisco IOS code in my document without any warning/error ?

Thank you in advance.

3 Answers 3

11

The style=tcblatex loads inputenc automatically.

Remove this key when used with xelatex or lualatex.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{booktabs}
\usepackage{etoolbox}
\usepackage[most]{tcolorbox}

\newtcblisting{cisco}[1][]{size=fbox, listing only, listing options={basicstyle=\ttfamily\scriptsize,tabsize=2,language=sh},#1}

\begin{document}

\begin{cisco}[title=Example of cisco command]
master#show ip cef 10.200.254.4
10.200.254.4/32, version 44, epoch 0, cached adjacency 10.200.200.2
0 packets, 0 bytes
    tag information set, all rewrites owned
    local tag: 20
    fast tag rewrite with Eth0/0/0, 10.200.200.2, tag imposed {18} via 10.200.200.2, Ethernet0/0/0, 0 dependencies
    next hop 10.200.200.2, Ethernet0/0/0
    valid cached adjacency
    tag rewrite with Et0/0/0, 10.200.200.2, tags imposed {18}
\end{cisco}

\end{document}
6

You have to pass the inputencoding=utf8 among the options of newtcblisting. This will pass the option to the inputenc package internally which is then redundant for the Xe/Lua LaTeX engines (you get a warning, about it not being necessary, that's it):

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{booktabs}
\usepackage{etoolbox}
\usepackage[most]{tcolorbox}

\newtcblisting{cisco}[1][]{size=fbox, listing only, listing options={style=tcblatex,basicstyle=\ttfamily\scriptsize,tabsize=2,language=sh,inputencoding=utf8},#1}

\begin{document}

\begin{cisco}[title=Example of cisco command]
master#show ip cef 10.200.254.4
10.200.254.4/32, version 44, epoch 0, cached adjacency 10.200.200.2
0 packets, 0 bytes
    tag information set, all rewrites owned
    local tag: 20
    fast tag rewrite with Eth0/0/0, 10.200.200.2, tag imposed {18} via 10.200.200.2, Ethernet0/0/0, 0 dependencies
    next hop 10.200.200.2, Ethernet0/0/0
    valid cached adjacency
    tag rewrite with Et0/0/0, 10.200.200.2, tags imposed {18}
\end{cisco}

\end{document}

giving:

enter image description here

2
  • 1
    The inputenc package is loaded still then, causing a warning. cough
    – user31729
    Commented May 17, 2017 at 18:13
  • 1
    @ChristianHupfer yes, but it is then discarded… atchoo
    – Moriambar
    Commented May 17, 2017 at 18:14
5

You can fool the package tcolorbox that inputenc is already loaded:

\documentclass{article}
\makeatletter\@namedef{[email protected]}{}\makeatother
\usepackage{fontspec}
\usepackage{booktabs}
\usepackage{etoolbox}
\usepackage[most]{tcolorbox}

\newtcblisting{cisco}[1][]{size=fbox, listing only, listing 
options={style=tcblatex,basicstyle=\ttfamily\scriptsize,tabsize=2,language=sh},#1}

\begin{document}

\begin{cisco}[title=Example of cisco command]
  master#show ip cef 10.200.254.4
  10.200.254.4/32, version 44, epoch 0, cached adjacency 10.200.200.2
  0 packets, 0 bytes
  tag information set, all rewrites owned
  local tag: 20
  fast tag rewrite with Eth0/0/0, 10.200.200.2, tag imposed {18} via 10.200.200.2, 
  Ethernet0/0/0, 0 dependencies
  next hop 10.200.200.2, Ethernet0/0/0
  valid cached adjacency
  tag rewrite with Et0/0/0, 10.200.200.2, tags imposed {18}
\end{cisco}

\end{document}

enter image description here

You must log in to answer this question.

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