Edit: this question is misinformed and the chosen answer answers a different question altogether.
\emph produces slightly better italicized text for certain symbols, e.g., punctuation. Right now, I use \itshape to force a style on a block of text.
\lstdefinelanguage{Scheme}{
% basewidth=0.5em,
sensitive=true,
basicstyle=\normalsize\rmfamily,
commentstyle=\itshape\rmfamily\color[rgb]{.9, .5,.1},
keywordstyle=\bfseries\sffamily\color[rgb]{0,.3,.7},
morecomment=[l]{;},
frameshape={RYR}{Y}{Y}{RYR},
identifierstyle=\emph\rmfamily,
keywords={define, lambda, let, cond, else},
escapeinside={(*;}{;*)},
columns=fullflexible
}
The problem is that I want to use \emph for "comments" in my listing and not just \itshape. Is there something similar that I can use (because I'd rather not have to escape and unescape every instance where I want to use \emph)?
Edit: it seems that \em is what I'm looking for, but my problem is more involved than that. The problem is that the identifierstyle doesn't italicize question marks using the above listing. See the image and code listing below.
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{listings, skins, breakable}
\definecolor{myorange}{rgb}{0.9, 0.5, 0.1}
\lstdefinelanguage{Scheme}{
% basewidth=0.5em,
sensitive=true,
basicstyle=\normalsize\rmfamily,
commentstyle=\itshape\rmfamily\color[rgb]{.9, .5,.1},
keywordstyle=\bfseries\sffamily\color[rgb]{0,.3,.7},
morecomment=[l]{;},
frameshape={RYR}{Y}{Y}{RYR},
identifierstyle=\em\rmfamily,
keywords={define, lambda, let, cond, else},
escapeinside={(;}{;)},
columns=fullflexible
}
\begin{document}
\begin{lstlisting}[language=Scheme]
;; rember(;\textcolor{myorange}{\textrm{:}};) (;\textcolor{myorange}{\textsf{Atom}};) (;\textcolor{myorange}{\textsf{[ListOf Atom]}};) (;\textcolor{myorange}{$\to$};) (;\textcolor{myorange}{\textsf{Atom}};)
;; Comment here...
(define rember
((;$\lambda$;) (a lat)
(cond
[(null? lat) (quote ())]
[else (cond
[(eqv? (car lat) a) (cdr lat)]
[else (rember a (cdr lat))])])))
\end{lstlisting}
\end{document}



\emand\emphand Why Different Commands for Seemingly Similar Tasks? – Mico Mar 17 '23 at 05:35\emphproducing “better italicized text”. Can you please explain? – egreg Mar 17 '23 at 08:08\textitdoes not italicize punctuation, which looks off when working with certain pieces of text. Perhaps it's better to just slightly redefine\textit? – TheProgrammer Mar 17 '23 at 16:42\textit{?}and see. – egreg Mar 17 '23 at 16:56\emor\itshape. The context is that I'm trying to use alstlistingto show some programming code. I want identifiers to use\rmstyleand\itshape. The problem is that everything but the question marks are italicized. I've updated my question. – TheProgrammer Mar 17 '23 at 17:27?in roman rather than italics is made by the language definition inlstlisting, and has nothing to do with font choices. I would look at the docs for lstlisting and if you’re not sure how to change the definition, ask a new question. – Don Hosek Mar 17 '23 at 20:01