3

I wish to customize the verb command such that I can customize the font and color, as well as set a rounded colored rectangle as background.

I found this in the Tcolorbox manual:

\DeclareTotalTCBox{\commandbox}{ s v }
{verbatim,colupper=white,colback=black!75!white,colframe=black}
{\IfBooleanTF{#1}{\textcolor{red}{\ttfamily\bfseries > }}{}%
\lstinline[language=command.com,keywordstyle=\color{blue!35!white}\bfseries]^#2^}

which appears to be similar to what I desire. However, I get numerous errors:

- Undefined control sequence
- You can't use `macro parameter character #' in horizontal mode.

This is the header code so far with the above included:

\documentclass[oneside,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[letterpaper, margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{mathpazo}
\usepackage{listings}
\usepackage{minted}
\usepackage{xcolor}
\usepackage{tcolorbox}
\usepackage{etoolbox}
\usepackage{tcolorbox}
\tcbuselibrary{listings, minted, skins}

\BeforeBeginEnvironment{minted}{\vspace{2mm}\begin{tcolorbox}[colback=bg, colframe=bg, arc=1.2pt]}%
\AfterEndEnvironment{minted}{\end{tcolorbox}\vspace{2mm}}%

\usepackage{newverbs}
\definecolor{inline}{RGB}{187,57,82}
\newverbcommand{\cverb}{\color{inline}}{}
\usemintedstyle{paraiso-dark}

\definecolor{bg}{RGB}{22,43,58}
\setminted{fontfamily=fdm, fontsize=\footnotesize, gobble=4, baselinestretch=1.2}

\DeclareTotalTCBox{\commandbox}{ s v }
{verbatim,colupper=white,colback=black!75!white,colframe=black}
{\IfBooleanTF{#1}{\textcolor{red}{\ttfamily\bfseries > }}{}%
\lstinline[language=command.com,keywordstyle=\color{blue!35!white}\bfseries]^#2^}

\setlength{\parindent}{0pt}
\title{\Huge{\textbf{Programming in C, Java, \& More}}}
\author{Richard Robinson, B.Eng. Cand.}

\begin{document} 
4

Use library xparse.

% arara: pdflatex: {shell: 1}
\documentclass[oneside,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[letterpaper, margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{mathpazo}
\usepackage{listings}
\usepackage{minted}
\usepackage{xcolor}
\usepackage{tcolorbox}
\usepackage{etoolbox}
\usepackage{tcolorbox}
\tcbuselibrary{listings, minted, skins, xparse}

\BeforeBeginEnvironment{minted}{\vspace{2mm}\begin{tcolorbox}[colback=bg, colframe=bg, arc=1.2pt]}%
\AfterEndEnvironment{minted}{\end{tcolorbox}\vspace{2mm}}%

\usepackage{newverbs}
\definecolor{inline}{RGB}{187,57,82}
\newverbcommand{\cverb}{\color{inline}}{}
\usemintedstyle{paraiso-dark}

\definecolor{bg}{RGB}{22,43,58}
\setminted{fontfamily=fdm, fontsize=\footnotesize, gobble=4, baselinestretch=1.2}

\DeclareTotalTCBox{\commandbox}{ s v }
{verbatim,colupper=red!75!black,colback=lightgray, enhanced, frame hidden, arc=2pt}
{\IfBooleanTF{#1}{\textcolor{red}{\ttfamily\bfseries > }}{}%
\lstinline[language=command.com,keywordstyle=\color{blue!35!white}\bfseries]^#2^}

\setlength{\parindent}{0pt}
\title{\Huge{\textbf{Programming in C, Java, \& More}}}
\author{Richard Robinson, B.Eng. Cand.}

\begin{document} 

\commandbox{ABC}

\end{document}

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.