listings add tag
topnush
I  am using the following code to typeset Python

```
\documentclass[12pt,a4paper]{article}
\usepackage{exsheets}
 \usepackage{exsheets-listings}
\SetupExSheets{
  headings = block-subtitle ,
  subtitle-format = \bfseries % default is \itshape
}
\usepackage{paralist}
\usepackage{amsfonts}
\usepackage{amsmath}
\DeclareMathOperator{\var}{var}
\DeclareMathOperator{\E}{\mathbb{E}}
\SetupExSheets{solution/print=true}
\SetupExSheets{question/type=exam}
\SetupExSheets[points]{name=point,name-plural=points}



% Default fixed font does not support bold face
\DeclareFixedFont{\ttb}{T1}{txtt}{bx}{n}{12} % for bold
\DeclareFixedFont{\ttm}{T1}{txtt}{m}{n}{12}  % for normal

% Custom colors
\usepackage{color}
\definecolor{deepblue}{rgb}{0,0,0.5}
\definecolor{deepred}{rgb}{0.6,0,0}
\definecolor{deepgreen}{rgb}{0,0.5,0}

\usepackage{listings}

% Python style for highlighting
\lstdefinestyle{mypython}{%
		language=Python,
		basicstyle=\ttm,
		otherkeywords={self},             % Add keywords here
		keywordstyle=\ttb\color{deepblue},
		emph={MyClass,__init__},          % Custom highlighting
		emphstyle=\ttb\color{deepred},    % Custom highlighting style
		stringstyle=\color{deepgreen},
		frame=tb,                         % Any extra options here
		showstringspaces=false            % 
}
% Python environment
\lstnewenvironment{python}[1][]
{
	\lstset{style=mypython,#1}
}
{}


\begin{document}
\begin{lstquestion}[%
  pre=Do something, 
  listings={style={mypython}}
]
# Some interesting comments that are enlightening.
print("Hello world!")
\end{lstquestion}

\end{document}
```

I don't like the way to comments look. The font is in italics and the letters are spread too far apart. It looks like it is a math formula or similar rather than comments in Englsh. What is the right way to do this?
Top Answer
samcarter
You can adjust the style of the comments via `commentstyle={...}`. Which font style you use is really just a matter of taste. For my own projects I normally use `\slshape`, this looks less mathy than real italics but is still easily distinguishable from the surrounding font.

The space between the letters depends on your `column` style. If you don't want the letters to be shown in a regular grid (which will mean larger spaces for some characters), you can try `columns=fullflexible`.

```
\documentclass[12pt,a4paper]{article}
\usepackage{exsheets}
 \usepackage{exsheets-listings}
\SetupExSheets{
  headings = block-subtitle ,
  subtitle-format = \bfseries % default is \itshape
}
\usepackage{paralist}
\usepackage{amsfonts}
\usepackage{amsmath}
\DeclareMathOperator{\var}{var}
\DeclareMathOperator{\E}{\mathbb{E}}
\SetupExSheets{solution/print=true}
\SetupExSheets{question/type=exam}
\SetupExSheets[points]{name=point,name-plural=points}



% Default fixed font does not support bold face
\DeclareFixedFont{\ttb}{T1}{txtt}{bx}{n}{12} % for bold
\DeclareFixedFont{\ttm}{T1}{txtt}{m}{n}{12}  % for normal

% Custom colors
\usepackage{color}
\definecolor{deepblue}{rgb}{0,0,0.5}
\definecolor{deepred}{rgb}{0.6,0,0}
\definecolor{deepgreen}{rgb}{0,0.5,0}

\usepackage{listings}

% Python style for highlighting
\lstdefinestyle{mypython}{%
		language=Python,
		basicstyle=\ttm,
		otherkeywords={self},             % Add keywords here
		keywordstyle=\ttb\color{deepblue},
		emph={MyClass,__init__},          % Custom highlighting
		emphstyle=\ttb\color{deepred},    % Custom highlighting style
		stringstyle=\color{deepgreen},
		frame=tb,                         % Any extra options here
		showstringspaces=false,            % 
    commentstyle={\slshape},     
    columns=fullflexible
}
% Python environment
\lstnewenvironment{python}[1][]
{
	\lstset{style=mypython,#1}
}
{}


\begin{document}
\begin{lstquestion}[%
  pre=Do something, 
  listings={style={mypython}}
]
# Some interesting comments that are enlightening.
print("Hello world!")
\end{lstquestion}

\end{document}
```

![Screenshot 2021-09-09 at 17.12.06.png](/image?hash=8ea75a7b6cb31cb4fd1835c72e3e312447fa9c92f2680cb6037ed06c726f9ca3)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.