Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- documentclass[a4paper, 10pt, oneside, fleqn, openright]{report}
- usepackage[no-math]{fontspec}
- usepackage{polyglossia}
- setdefaultlanguage{french}
- setotherlanguages{english}
- newcommand{codeimg}{$vcenter{hbox{includegraphics[height=baselineskip]{example-image-a}}}$}
- usepackage{calc}
- usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
- usepackage{pdfpages,graphicx}
- usepackage{mdframed}
- usepackage{listings}
- usepackage{filecontents}
- definecolor{light-gray}{gray}{0.92}
- definecolor{mainColor}{RGB}{211, 47, 47} % some dark red
- usepackage{tcolorbox}
- newcounter{data}
- newcounter{result}
- newcounter{pythoncode}
- newcounter{matlab}
- tcbuselibrary{skins,breakable,listings}
- newtcblisting[use counter=lstlisting]{codeblock}[2][]{%
- enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
- fonttitle=bfseries,
- before upper={hspace*{-1em}codeimg~#2},%
- title after break={centeringfootnotesizeitshapestrutlstlistingname~thelstlisting~--~continued},%
- listing only,listing options={xleftmargin=-1mm},
- after upper={centeringstrutlstlistingname~thelstlisting:~#2},
- frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,frame code={draw[gray,line width=2mm] ([xshift=-0.5pt]frame.north west) -- ([xshift=-0.5pt]frame.south west);},#1}
- newtcbinputlisting[use counter=matlab,list inside=matlab,number within=chapter]{inputmatlab}[3][]{%
- enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
- fonttitle=bfseries,before upper={hspace*{-1em}codeimg~#3},%
- title after break={centeringfootnotesizeitshapestrut Matlab Code~thematlab~--~continued},%
- listing only,listing options={xleftmargin=-1mm,#1,style=Matlab-editor,basicstyle=ttfamilyscriptsize},
- after upper={centeringstrut {bfseries Matlab Code~thematlab:}~#2},
- frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,
- %
- listing file={#3},#1}
- usepackage[numbered,framed]{matlab-prettifier}
- begin{filecontents*}{sol2_adx.m}
- % create a file for output
- !touch testFile.txt
- fid = fopen('testFile.text', 'w')
- for i=1:10
- fprintf(fid,'%6.2f n', i);
- end
- end{filecontents*}
- begin{document}
- inputmatlab{Expansion Algorithm}{sol2_adx.m}
- end{document}
- documentclass{article}
- usepackage{matlab-prettifier}
- usepackage{tcolorbox}
- tcbuselibrary{listings}
- % use filename@parse to strip the path from filename
- % also allow underscore in filename
- makeatletter
- begingroup
- catcode`_active
- gdefstrippath#1{%
- filename@parse{#1}%
- begingroup
- catcode`_active
- let_textunderscore
- edeffname{filename@base .filename@ext}%
- scantokensexpandafter{fname}%
- endgroup
- }
- endgroup
- makeatother
- % simplified inputlisting definition
- % note before upper uses strippath defined above
- newtcbinputlisting{inputmatlab}[3][]{%
- before upper = textbf{strippath{#3}},
- listing only,
- listing options = {#1,style=Matlab-editor,basicstyle=ttfamily},
- listing file = {#3},
- #1}
- begin{document}
- inputmatlab{Expansion Algorithm}{subdir/sol2_adx.m}
- end{document}
Add Comment
Please, Sign In to add comment