SHARE
TWEET

Untitled

a guest Nov 15th, 2017 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. documentclass[a4paper, 10pt, oneside, fleqn, openright]{report}
  2. usepackage[no-math]{fontspec}
  3.  
  4. usepackage{polyglossia}
  5. setdefaultlanguage{french}
  6. setotherlanguages{english}
  7.  
  8. newcommand{codeimg}{$vcenter{hbox{includegraphics[height=baselineskip]{example-image-a}}}$}
  9.  
  10. usepackage{calc}
  11. usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
  12. usepackage{pdfpages,graphicx}
  13. usepackage{mdframed}
  14. usepackage{listings}
  15. usepackage{filecontents}
  16. definecolor{light-gray}{gray}{0.92}
  17.  
  18. definecolor{mainColor}{RGB}{211, 47, 47} % some dark red
  19.  
  20.  
  21. usepackage{tcolorbox}
  22. newcounter{data}
  23. newcounter{result}
  24. newcounter{pythoncode}
  25. newcounter{matlab}
  26. tcbuselibrary{skins,breakable,listings}
  27. newtcblisting[use counter=lstlisting]{codeblock}[2][]{%
  28.         enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
  29.         fonttitle=bfseries,
  30.         before upper={hspace*{-1em}codeimg~#2},%
  31.         title after break={centeringfootnotesizeitshapestrutlstlistingname~thelstlisting~--~continued},%
  32.         listing only,listing options={xleftmargin=-1mm},
  33.         after upper={centeringstrutlstlistingname~thelstlisting:~#2},
  34.         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}
  35.  
  36. newtcbinputlisting[use counter=matlab,list inside=matlab,number within=chapter]{inputmatlab}[3][]{%
  37.         enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
  38.         fonttitle=bfseries,before upper={hspace*{-1em}codeimg~#3},%
  39.     title after break={centeringfootnotesizeitshapestrut Matlab Code~thematlab~--~continued},%
  40.      listing only,listing options={xleftmargin=-1mm,#1,style=Matlab-editor,basicstyle=ttfamilyscriptsize},
  41.      after upper={centeringstrut {bfseries Matlab Code~thematlab:}~#2},
  42.      frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,
  43.      %
  44.      listing file={#3},#1}
  45.  
  46. usepackage[numbered,framed]{matlab-prettifier}
  47.  
  48. begin{filecontents*}{sol2_adx.m}
  49. % create a file for output
  50. !touch testFile.txt
  51. fid = fopen('testFile.text', 'w')
  52. for i=1:10
  53.   fprintf(fid,'%6.2f n', i);
  54. end
  55. end{filecontents*}
  56.  
  57. begin{document}
  58.  
  59. inputmatlab{Expansion Algorithm}{sol2_adx.m}    
  60. end{document}
  61.    
  62. documentclass{article}
  63.  
  64. usepackage{matlab-prettifier}
  65. usepackage{tcolorbox}
  66. tcbuselibrary{listings}
  67.  
  68. % use filename@parse to strip the path from filename
  69. % also allow underscore in filename
  70. makeatletter
  71. begingroup
  72. catcode`_active
  73. gdefstrippath#1{%
  74.   filename@parse{#1}%
  75.   begingroup
  76.   catcode`_active
  77.   let_textunderscore
  78.   edeffname{filename@base .filename@ext}%
  79.   scantokensexpandafter{fname}%
  80.   endgroup
  81. }
  82. endgroup
  83. makeatother
  84.  
  85. % simplified inputlisting definition
  86. % note before upper uses strippath defined above
  87. newtcbinputlisting{inputmatlab}[3][]{%
  88.   before upper = textbf{strippath{#3}},
  89.   listing only,
  90.   listing options = {#1,style=Matlab-editor,basicstyle=ttfamily},
  91.   listing file = {#3},
  92.   #1}
  93.  
  94. begin{document}
  95. inputmatlab{Expansion Algorithm}{subdir/sol2_adx.m}    
  96. end{document}
RAW Paste Data
Top