General ⇒ Indent full paragraph
Indent full paragraph
I have a small problem with Latex.
I want to indent a full paragraph, not only the first line. The only solution I found is to use \begin{quote}. I don't like this at all because I don't want an indention at the right site.
Maybe I can create a quote-like environment with left-only indent!?
Thanks for you help!
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
Indent full paragraph
Aurora wrote: Maybe I can create a quote-like environment with left-only indent!?
Sure you can. Try something like the following
Code: Select all
\newenvironment{myindentpar}[1]%
{\begin{list}{}%
{\setlength{\leftmargin}{#1}}%
\item[]%
}
{\end{list}}
Code: Select all
\begin{myindentpar}{3cm}
text text text...
\end{myindentpar}
Indent full paragraph
But I have some questions for understanding.
- Are the percent-symbols (%) important for functionality?
- in this line: \newenvironment{myindentpar}[1]%. [1] is a variable for the first parameter!?
Indent full paragraph
Aurora wrote: Are the percent-symbols (%) important for functionality?
Not really (in this case).
Aurora wrote: in this line: \newenvironment{myindentpar}[1]%. [1] is a variable for the first parameter!?
[1] indicates that the myindentpar environment has one argument (in this case, the length you want to use to indent your paragraph).
-
- Posts: 9
- Joined: Tue Jul 08, 2008 10:25 pm
Re: Indent full paragraph
Indent full paragraph
nieproszenieja wrote:There is a better way to do this - command ' \hangindent=length ' (e.g. \hangindent=1cm, etc.) inside paragraph do the trick.

Please, explain what you mean with better:
Code: Select all
\documentclass{article}
\usepackage{lipsum}
\newenvironment{myindentpar}[1]%
{\begin{list}{}%
{\setlength{\leftmargin}{#1}}%
\item[]%
}
{\end{list}}
\begin{document}
\lipsum[1]
\begin{myindentpar}{1cm}
\lipsum[1]
\end{myindentpar}
\hangindent=1cm
\lipsum[1]
\end{document}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Indent full paragraph
In this case the \hangindent command should be combined with the \hangafter command, which sets the number of lines typeset without indentation. The default setting is one line.nieproszenieja wrote:There is a better way to do this - command ' \hangindent=length ' (e.g. \hangindent=1cm, etc.) inside paragraph do the trick.
Code: Select all
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage[bindingoffset=1cm,centering,includeheadfoot,margin=2cm]{geometry}
\usepackage{blindtext}
\usepackage{txfonts}
\parindent0em
\begin{document}
\hangindent2em
\hangafter=0
\blindtext
\medskip
\blindtext
\end{document}
Best regards
Thorsten¹
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 9
- Joined: Tue Jul 08, 2008 10:25 pm
Indent full paragraph
Replace 1cm with \parindent (\hangindent=\parindent), the result will be quite the same as yours.gmedina wrote:Code: Select all
\documentclass{article} \usepackage{lipsum} \begin{document} %(some code....) \hangindent=1cm \lipsum[1] \end{document}
You can also put 'setlength{\parindent}{1cm}' before '\hangindent=1cm', then the result will be the same.
EDIT: tex command \hangafter has also one usefull option (from tex refrence card):
\hangafter = (number) start hanging indent after line n.
If n < 0, indent first |n| lines.
Indent full paragraph
The solution I found was to create an invisible table with no internal space in cells.
Code: Select all
%===============Variables
\def \constzeroindent {0cm}
\def \constfirstindent {0.5cm}
\def \constsecondindent {1cm}
%===============Macros
\newenvironment{mycustomindent}[1]
{\setlength{\parindent}{#1}}
{\setlength{\parindent}{\constzeroindent}}
\newcommand{\myindentedpar}[1]{
\begin{mycustomindent}{\constsecondindent}
\begin{tabular}{@{}p{17cm}@{}}
#1 \\
\end{tabular}
\end{mycustomindent}}
%===============Use
\myindentedpar{Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.}