1

I'm writing MATLAB code in LaTeX and I would like to be able to cut and paste it directly into the MATLAB command window. One critical symbol is the ' (single quote). When processed by LaTeX it shows up as a curly quote sign, which MATLAB doesn't recognize. I've looked through the "Comprehensive Symbol Table", but I couldn't find anything. The csquotes package looks as though it might be helpful, but I found the manual incomprehensible.

1

Discovered the answer, related to Paul Gessler's comment. There's a wonderful style file called mcode.sty that uses the listings package but seems to deal with some of it's shortcomings.

http://www.mathworks.com/matlabcentral/fileexchange/8015-m-code-latex-package

  • You should have a look at the matlab-prettifier package; it improves upon mcode in many ways. See this answer, for instance. – jub0bs Apr 14 '16 at 23:29
  • Thanks very much, I made the switch! Took a bit of work to set it up, but seem to have succeeded. I may learn other advantages as I got, but the main reason I converted was being able to place inline matlab commands with double quotes, e.g., in matlab, "sym" means... That facility is worth a lot to me! Is there an easy option to add color to all inline statements, i.e., anything separated by "'s? Also, while Beta Mono is much nicer than the default, it would be nice if I could use a non monospaced font just for comments, i.e, anything after a % sign. Is that possible? – Leo Simon Apr 15 '16 at 22:37
  • 1
    Is there an easy option to add color to all inline statements, i.e., anything separated by "'s? What you mean is unclear, but know that you can alter the style of inline code when defining " as a shorthand with \lstMakeShortInline". Try, for instance, \lstMakeShortInline[basicstyle=\color{red}]". [...] it would be nice if I could use a non monospaced font just for comments, i.e, anything after a % sign. Simply pass the desired style to the mlcommentstyle key, e.g. mlcommentstyle = \rmfamily\color[RGB]{034,139,034}. – jub0bs Apr 16 '16 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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