Skip to content

Instantly share code, notes, and snippets.

@rulojuka
Created May 9, 2019 05:30
Show Gist options
  • Save rulojuka/ff4c0986704eb4a2b1bda23c2b2a28ca to your computer and use it in GitHub Desktop.
Save rulojuka/ff4c0986704eb4a2b1bda23c2b2a28ca to your computer and use it in GitHub Desktop.
Nice latex listing configuration for octave
% Based on https://lists.gnu.org/archive/html/octave-maintainers/2013-05/msg00366.html
\usepackage{listings}
\usepackage[dvipsnames]{xcolor}
\usepackage[portuguese]{babel}
\lstset{
language=Octave,
backgroundcolor=\color{white}, % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
basicstyle=\footnotesize\ttfamily, % the size of the fonts that are used for the code
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
breaklines=true, % sets automatic line breaking
captionpos=b, % sets the caption-position to bottom
commentstyle=\color{gray}, % comment style
%escapeinside={\%*}{*)}, % if you want to add LaTeX within your code
extendedchars=true, % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
frame=single, % adds a frame around the code
% frameround=fttt,
keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
classoffset=0,
keywordstyle=\color{RoyalBlue}, % keyword style
deletekeywords={function,endfunction, if,endif},
classoffset=1,
morekeywords={function,endfunction, if,endif},
keywordstyle=\bf\color{Red}, % keyword style
classoffset=2,
morekeywords={persistent}, % if you want to add more keywords to the set
keywordstyle=\bf\color{ForestGreen}, % keyword style
classoffset=0,
literate=
{/}{{{\color{Mahogany}/}}}1
{*}{{{\color{Mahogany}*}}}1
{.*}{{{\color{Mahogany}.*}}}2
{+}{{{\color{Mahogany}+{}}}}1
{=}{{{\bf\color{Mahogany}=}}}1
{-}{{{\color{Mahogany}-}}}1
{[}{{{\bf\color{RedOrange}[}}}1
{]}{{{\bf\color{RedOrange}]}}}1
{ç}{{\c{c}}}1 % Cedilha
{á}{{\'{a}}}1 % Acentos agudos
{é}{{\'{e}}}1
{í}{{\'{i}}}1
{ó}{{\'{o}}}1
{ú}{{\'{u}}}1
{â}{{\^{a}}}1 % Acentos circunflexos
{ê}{{\^{e}}}1
{î}{{\^{i}}}1
{ô}{{\^{o}}}1
{û}{{\^{u}}}1
{à}{{\`{a}}}1 % Acentos graves
{è}{{\`{e}}}1
{ì}{{\`{i}}}1
{ò}{{\`{o}}}1
{ù}{{\`{u}}}1
{ã}{{\~{a}}}1 % Tils
{ẽ}{{\~{e}}}1
{ĩ}{{\~{i}}}1
{õ}{{\~{o}}}1
{ũ}{{\~{u}}}1,
numbers=left, % where to put the line-numbers; possible values are (none, left, right)
numbersep=6pt, % how far the line-numbers are from the code
numberstyle=\tiny\color{gray}, % the style that is used for the line-numbers
rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
showstringspaces=false, % underline spaces within strings only
showtabs=false, % show tabs within strings adding particular underscores
stepnumber=1, % the step between two line-numbers. If it's 1, each line will be numbered
stringstyle=\color{purple}, % string literal style
tabsize=2, % sets default tabsize to 2 spaces
title=\lstname, % show the filename of files included with \lstinputlisting; also try caption instead of title
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment