-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmatlab.sty
100 lines (78 loc) · 1.8 KB
/
matlab.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{matlab}
\RequirePackage{listings}
\RequirePackage{hyperref}
\RequirePackage{color}
\newcommand{\maxwidth}[1]{\ifdim\linewidth>#1 #1\else\linewidth\fi}
\newcommand{\mlcell}[1]{\lstinline[style=matlaboutputstyle]$#1$}
\definecolor{output}{gray}{0.5}
% Paragraph indentation
\setlength{\parindent}{0pt}
% Hyperlink style
\hypersetup{
colorlinks=true,
linkcolor=blue,
urlcolor=blue
}
% Listings environment styles for MATLAB code and output
\lstset{
extendedchars=\true,
inputencoding=utf8
}
\lstnewenvironment{matlabcode}{
\lstset{
frame=single,
framesep=0.75em,
xleftmargin=1em,
breaklines=true,
prebreak=\ldots,
breakatwhitespace=true,
literate={-}{-}1 {+}{+}2 {\_}{\_}2 {\#}{\#}2 {\%}{\%}2 {\&}{\&}2 {<}{<}2 {=}{=}2 {>}{>}2 {\^}{\textasciicircum{}}2
}
}{}
\lstnewenvironment{matlaboutput}{
\lstset{
style=matlaboutputstyle
}
}{}
\lstnewenvironment{matlabsymbolicoutput}{
\lstset{
style=matlaboutputstyle,
mathescape=true
}
}{}
\lstdefinestyle{matlaboutputstyle}{
basicstyle=\color{output},
belowskip=0pt,
aboveskip=0pt,
xleftmargin=1.25em,
literate={-}{-}1 {+}{+}2 {\_}{\_}2 {\#}{\#}2 {\%}{\%}2 {\&}{\&}2 {<}{<}2 {=}{=}2 {>}{>}2 {\^}{\textasciicircum{}}2
}
\newenvironment{matlabtableoutput}[1]{
{\color{output}
\hspace*{1.25em}#1
}
}{}
% Table of Contents style
\newcounter{multititle}
\newcommand{\matlabmultipletitles}{\setcounter{multititle}{1}}
\newcounter{hastoc}
\newcommand{\matlabhastoc}{\setcounter{hastoc}{1}}
\newcommand{\matlabtitle}[1]{
\ifnum\value{multititle}>0
\ifnum\value{hastoc}>0
\addcontentsline{toc}{section}{#1}
\fi
\fi
\section*{#1}
}
\newcommand{\matlabheading}[1]{
\ifnum\value{hastoc}>0
\addcontentsline{toc}{subsection}{#1}
\fi
\subsection*{#1}
}
\newcommand{\matlabtableofcontents}[1]{
\renewcommand{\contentsname}{#1}
\tableofcontents
}