How to make a local indent in LaTex?

When we are writing code, editors will usually make an local indent for a logic block (shift rightwards uniformly in this block), for example, if...else..., or for (...){ }

However, I also want to apply this convention to mathematics note-writing (thus, the pdf form produced, not the about the .tex file) , for a clearer logic frame (like, a proof below a statement). Better, such local indent environment should be able to nest itself any times whenever we want to make a further local indent inside it.

"\begin / \end {itemize}" has already been able to indent itself, but I just don't want an itemize here.

• Welcome to the site. Does your question refer to indentation in the editing window (tex file), or on the paper document (i.e., PDF) produced by LaTeX? If the tex file, then it is a function of the editor you are using. If you are talking about a code listing in the output PDF, then it is a function of what environments you use to format the code. – Steven B. Segletes Sep 26 '18 at 18:12
• Thank you! @StevenSegletes Sorry, I didn't illustrate. It's about the pdf. – Collin Sep 26 '18 at 18:17
• So, are you looking for something like "pseudo code"? tex.stackexchange.com/search?q=pseudo+code – Steven B. Segletes Sep 26 '18 at 18:22
• @StevenB.Segletes Well, I don't think so. I'll put another way. I hope to define a simple environment that behaves very much like 'itemize' in terms of its local indent effect ( but of course I don't need to enumerate anything here). Further, possibly, it able to change the text font also, so that the proof part in such a math note looks very distinguishable from the usual statement. – Collin Sep 26 '18 at 18:31
• There are various indenting environments, such as quote and description, in addition to itemize and enumerate. With the enumitem package, you have great flexibility to structure the appearance and labels as you wish. If none of these suit you, one can fudge indenting environments with \leftskip and \rightskip. A picture of what you want would really help. – Steven B. Segletes Sep 26 '18 at 18:37

If you really need this, define your own special environment with the genral \list macro. Eg:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\newenvironment{myenv}
{\list{}{\rightmargin} \item\slshape\relax}{\endlist}
\begin{document}
\layout
\lipsum[1]
\begin{myenv}
\lipsum[2]
\end{myenv}
\lipsum[3]
\end{document}


Here i have added \slshape as you said "able to change the text font also", but you obviously can adapt the formatting to your need.