3
\documentclass[a4paper,12pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{tcolorbox}

\lstdefinestyle{mystyle}{
    basicstyle=\ttfamily\normalsize,
    commentstyle={\itshape\color{blue}},
    morecomment=[l]{'},
}

\lstset{style=mystyle}

\tcbset{width=\textwidth,boxrule=0pt,colback=yellow!25!white,arc=0pt,auto outer arc,left=0pt,right=0pt,boxsep=0pt}

\begin{document}

\begin{tcolorbox}               
\begin{lstlisting}
 Device = 18F452  'Microchip Name
\end{lstlisting}
\end{tcolorbox}
    
\end{document}

The output of this code is as follows.

enter image description here

However, I need to change the ' sign instead of the ’ sign. What are your suggestions?

Like: enter image description here

2

1 Answer 1

4

You could use the upquote package to get upright quotes in verbatim:

\documentclass[a4paper,12pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{tcolorbox}

\usepackage{upquote}

\lstdefinestyle{mystyle}{
    basicstyle=\ttfamily\normalsize,
    commentstyle={\itshape\color{blue}},
    morecomment=[l]{'},
}

\lstset{style=mystyle}

\tcbset{width=\textwidth,boxrule=0pt,colback=yellow!25!white,arc=0pt,auto outer arc,left=0pt,right=0pt,boxsep=0pt}

\begin{document}

\begin{tcolorbox}               
\begin{lstlisting}
 Device = 18F452  'Microchip Name
\end{lstlisting}
\end{tcolorbox}
    
\end{document}

You must log in to answer this question.

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