GeneralIndented text for code example

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
leireaz
Posts: 3
Joined: Mon Feb 04, 2008 5:06 pm

Indented text for code example

Post by leireaz »

Hi!

I need to add in a report a piece of code i wrote in matlab. I though I could do that with \begin{quote} ... \end{quote}. The problem is that it doesn't keep the indentation. Does anyone know how to make the text as it looks like in matlab?

Thanks

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Indented text for code example

Post by gmedina »

The listings packages could be useful as well as some of the suggestions that Juanjo made on this other thread.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
leireaz
Posts: 3
Joined: Mon Feb 04, 2008 5:06 pm

Re: Indented text for code example

Post by leireaz »

Thanks for your reply, gmedina.

I was wondering if there was an environment that could recognize the indentation, but I guess that I have to do it manually.

Thanks again
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Indented text for code example

Post by gmedina »

Of course there is such environment, take a look at the following example:

Code: Select all

\documentclass{article}

\begin{document}

\begin{verbatim}
text
  text
    text
      text 
\end{verbatim}

\end{document}
I suggested the listings package because it helps you to typeset programming code within LaTeX.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
leireaz
Posts: 3
Joined: Mon Feb 04, 2008 5:06 pm

Re: Indented text for code example

Post by leireaz »

Thank you very much!

That is exactly what I was looking for!
Post Reply