LaTeX forum ⇒ Text FormattingFormatting Matlab file with lstlsting

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
bearniva
Posts: 1
Joined: Fri Jan 03, 2020 12:28 pm

Formatting Matlab file with lstlsting

Postby bearniva » Fri Jan 03, 2020 12:36 pm

Hello!
I included a Matlab file, and it worked fine. The colors changed and it looked nice. Suddenly Latex doesn't change the colors of the code, except of the background color. Is something wrong with my code? Or is there a possibility that a included package is disturbing the code?
Thank you very much for answering!



Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass[12pt, xcolor=dvipsnames]{scrartcl}
  2.  
  3. \usepackage{listings}
  4. \usepackage[dvipsnames]{xcolor}
  5.  
  6. \definecolor{codegreen}{rgb}{0,0.6,0}
  7. \definecolor{codegray}{rgb}{0.5,0.5,0.5}
  8. \definecolor{codepurple}{rgb}{0.58,0,0.82}
  9. \definecolor{mygreen}{RGB}{28,172,0}
  10. \definecolor{mylilas}{RGB}{170,55,241}
  11. \definecolor{backcolour}{rgb}{0.95,0.95,0.92}
  12.  
  13. \begin{document}
  14.  
  15. \lstdefinestyle{mystyle}{
  16. backgroundcolor=\color{backcolour},
  17. commentstyle=\color{codegreen},
  18. keywordstyle=\color{blue},
  19. numberstyle=\tiny\color{codegray},
  20. stringstyle=\color{codepurple},
  21. basicstyle=\ttfamily\scriptsize,
  22. breakatwhitespace=false,
  23. breaklines=true,
  24. captionpos=b,
  25. keepspaces=true,
  26. numbers=left,
  27. numbersep=5pt,
  28. showspaces=false,
  29. showstringspaces=false,
  30. showtabs=false,
  31. tabsize=2,
  32. aboveskip=\medskipamount
  33. }
  34. \lstset{style=mystyle}
  35.  
  36. \lstinputlisting{adj.m}
  37. \end{document}
Attachments
Bildschirmfoto 2020-01-03 um 11.31.48.png
Pdf output
Bildschirmfoto 2020-01-03 um 11.31.48.png (106.82 KiB) Viewed 374 times

Bartman
Posts: 103
Joined: Fri Jan 03, 2020 2:39 pm

Postby Bartman » Sat Jan 04, 2020 2:52 am

You have not selected the language you want to use. Add language=Matlab to your style definition.


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 2 guests