LaTeX forum ⇒ New Memberstemplate book

You would like to introduce yourself before starting to post? That's a nice idea and here is the forum for you...
Shahrok_Esmaeili
Posts: 1
Joined: Fri May 31, 2019 10:59 pm

template book

Postby Shahrok_Esmaeili » Fri May 31, 2019 11:07 pm

Hi,
I use your template book.
I want to crate an ‎environment aligning with text margin for Matlab codes like ‎‎‎\‎newenvironment{theorem} , ...
Some tools are provided, however, I cant assemble them.

  1. \documentclass{article}‎
  2. ‎\usepackage{tikz}‎
  3. \RequirePackage[framemethod=‎TikZ‎]{‎mdframed}
  4.  
  5. % ‎Matlab‎ box
  6. \newmdenv[skipabove=7pt‎, ‎skipbelow=7pt‎,
  7. backgroundcolor=black!5‎, ‎linecolor=ocre‎, ‎innerleftmargin=5pt‎,
  8. innerrightmargin=5pt‎, ‎innertopmargin=5pt‎, ‎leftmargin=0cm‎,
  9. rightmargin=0cm‎,‎‎ roundcorner=‎5‎‎‎pt,‎
  10. innerbottommargin=5pt]{‎m‎Box}‎‎
  11.  
  12. ‎‎‎\‎newenvironment{matlabcode}{\begin{mBox}??????\end{mBox}}
  13. % including verbatim (if it is possible)
  14. \begin{document}
  15.  
  16. \begin{matlabcode}
  17. a = w*f;
  18. k = sin(x);
  19. \end{matlabcode}
  20.  
  21. \end{document}

mas
Posts: 219
Joined: Thu Dec 04, 2008 4:39 am

Postby mas » Sun Jun 02, 2019 3:14 am

Take a look at the package `listings' package. If you want to go fancy, then use `tcolorbox'.

  1. \documentclass{article}
  2.  
  3. \usepackage{listings}
  4.  
  5. \begin{document}
  6.  
  7. \noindent
  8. This is a piece of octave code:
  9.  
  10. \lstset{language=octave}
  11. \begin{lstlisting}
  12. octave:2> a * 10.5
  13. ans = 105
  14. octave:3> (a * 34.5)/(a - 12)
  15. ans = -172.50
  16. \end{lstlisting}
  17.  
  18. \end{document}


Replace octave by Matlab.

x.png
x.png (4.03 KiB) Viewed 166 times

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim


Return to “New Members”

Who is online

Users browsing this forum: No registered users and 3 guests