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...
Post Reply
Shahrok_Esmaeili
Posts: 1
Joined: Fri May 31, 2019 10:59 pm

template book

Post by Shahrok_Esmaeili »

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.

Code: Select all

\documentclass{article}‎
‎\usepackage{tikz}‎
‎\RequirePackage[framemethod=‎TikZ‎]{‎mdframed}    

% ‎Matlab‎ box
\newmdenv[skipabove=7pt‎, ‎skipbelow=7pt‎,
backgroundcolor=black!5‎, ‎linecolor=ocre‎, ‎innerleftmargin=5pt‎,
innerrightmargin=5pt‎, ‎innertopmargin=5pt‎, ‎leftmargin=0cm‎,
rightmargin=0cm‎,‎‎ roundcorner=‎5‎‎‎pt,‎
innerbottommargin=5pt]{‎m‎Box}‎‎

‎‎‎\‎newenvironment{matlabcode}{\begin{mBox}??????\end{mBox}}
% including verbatim (if it is possible)
\begin{document}    

\begin{matlabcode}
  a = w*f;
  k = sin(x);
\end{matlabcode}

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

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

template book

Post by mas »

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

Code: Select all

\documentclass{article}

\usepackage{listings}

\begin{document}

\noindent
This is a piece of octave code:

\lstset{language=octave}
\begin{lstlisting}
octave:2> a * 10.5
ans =  105
octave:3> (a * 34.5)/(a - 12)
ans = -172.50                                                                         
\end{lstlisting} 

\end{document}
Replace octave by Matlab.
x.png
x.png (4.03 KiB) Viewed 3367 times

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