0

How i can deledete comment from listings code? I included source code file with \lstinputlisting{file.m} where file.m is matlab file. I want delete comment from file. % This is a comment function var = myfunction()

I tried to use comment commentstyle=\color{white} but the result isn't as I expected cause between code there are some withe line that i want totally remove.

Thanks in advance

marked as duplicate by TeXnician, Phelype Oleinik, Zarko, Stefan Pinnow, Bobyandbob May 2 '18 at 17:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

Just use the right delimiters instead of the ones in my code.

\documentclass{standalone}
\usepackage{listings}
\lstset{morecomment=[is]{/*}{*/}}
\begin{document}
\begin{lstlisting}
begin /* comment */ end
/* no comment but a blank line remains */
begin/* comment */end
\end{lstlisting}
\end{document}

example_image

Unfortunately, you cannot get rid of the blank line.

Reference: Delimiters in listings manual

  • I didn't saw the comment from moewe. I think that the links that he provided are more useful than my anwer. ;) – gvgramazio May 2 '18 at 15:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.