listings package allows setting basicstyle, keywordstyle, identifierstyle,
commentstyle, stringstyle. Is it possible to set different style for comments that start from /**
not just /*
?
To make my question more clear. Assume I have set environment
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[svgnames]{xcolor}
\usepackage{listings}
\usepackage[scaled=0.92]{beramono}
\usepackage[scaled=0.92]{berasans}
\usepackage[scaled=0.92]{beraserif}
\lstnewenvironment{MyCode}
{\lstset{
language=C++,
basicstyle=\fontfamily{fvm}\selectfont,
keywordstyle=\bfseries,
identifierstyle=\color{blue},
commentstyle=\fontfamily{fve}\selectfont\color{olive},
stringstyle=\fontfamily{fvs}\selectfont,
frame=single,showstringspaces=false,columns=flexible} }
{}
and I have the following code
\begin{document}
\begin{MyCode}
/*
Multi-line
non-Doxygen comments
*/
#include <iostream>
/** Single-line Doxygen comment */
class MyClass {
private:
int value; /**< After member Doxygen comment */
public:
/**
* Multi-line Doxygen comment
* @param int x new value
* @return bool operation success
*/
bool setValue(int x /**< [in] also Doxygen */) {
this->value = x; /* non-Doxygen comment */
std::cout << "I'm setting value " << x << std::endl;
/* Single line non-Doxygen comment */
return true;
}
};
\end{MyCode}
\end{document}
There are mixed:
- usual comments starting with
/*
- Doxygen (javadoc) comments starting with
/**
/**
itself starts with /*
so all comments are formatted according to
commentstyle=\fontfamily{fve}\selectfont\color{olive},
Is it possible to distinguish between those comments and set another style for /**
comments? For example color them red not olive.
\documentclass{...}
, the required\usepackage
's,\begin{document}
, and\end{document}
. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.