Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

While using mcode.sty, I recognized that at linebreaks with long comments parts of the surrounding frame got colored green or were even left white at using mathematical formulas, e.g. in the following example:

\documentclass{article}

% load package with ``framed'' and ``numbered'' option.
\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}

% something NOT relevant to the usage of the package.
\setlength{\parindent}{0pt}
\setlength{\parskip}{18pt}

\begin{document}
\begin{itemize}
\item The following demo block shows the problems:
\begin{lstlisting}
for i = 1:3
    if i >= 5                    % literate programming replacement
        disp('cool');           % comment with some §\mcommentfont\LaTeX in it: $\mcommentfont\pi x^2$§
    end
    really really long really really long really really long really really long really really long line % blaaaaaaaa
end
\end{lstlisting}
\end{itemize}
\end{document}

How can uniformly black colored frames be achieved?

share|improve this question
    
I have removed my previous comment, I misinterpreted your question. –  Dennis Jaheruddin Feb 13 '13 at 13:33
    
You forgot to include a list-environment (e.g. itemize) in your code. The problem only seems to occur in a list, if you remove the \item from your code everything works fine. –  Torbjørn T. Feb 13 '13 at 19:53
    
@TorbjørnT.: Thank you for your comment - that environment enabled me to see the bug (because of the smaller textwidth)! –  strpeter Feb 15 '13 at 8:12
    
I hope now people can see the remaining problem/conflict of the frame with math code inside the lstlisting-environment. –  strpeter Feb 15 '13 at 8:17
1  
You might want to use the matlab-prettifier package; see this answer. –  Jubobs Mar 18 at 0:25

1 Answer 1

The first problem can be solved (I think it is a bug in the package mcode.sty) quite simply by adding a few lines of code just after including \usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}:

\lstset{
    rulecolor=\color{black}
}

The problem at using mathematical formulas still remains.

share|improve this answer
    
Please consider accepting your own answer, so that it be removed from the pile of "unanswered" questions. –  Jubobs Mar 18 at 0:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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