GeneralIndent full paragraph

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Aurora
Posts: 17
Joined: Thu Jun 28, 2007 3:42 pm

Indent full paragraph

Post by Aurora »

hi there,

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!

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

Indent full paragraph

Post by gmedina »

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}}
And use it like this:

Code: Select all

\begin{myindentpar}{3cm}
text text text...
\end{myindentpar}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Aurora
Posts: 17
Joined: Thu Jun 28, 2007 3:42 pm

Indent full paragraph

Post by Aurora »

Thank you very much. Works great.

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!?
Thanks so far.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Indent full paragraph

Post by gmedina »

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).
1,1,2,3,5,8,13,21,34,55,89,144,233,...
nieproszenieja
Posts: 9
Joined: Tue Jul 08, 2008 10:25 pm

Re: Indent full paragraph

Post by nieproszenieja »

There is a better way to do this - command ' \hangindent=length ' (e.g. \hangindent=1cm, etc.) inside paragraph do the trick.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Indent full paragraph

Post by gmedina »

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}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Indent full paragraph

Post by localghost »

nieproszenieja wrote:There is a better way to do this - command ' \hangindent=length ' (e.g. \hangindent=1cm, etc.) inside paragraph do the trick.
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.

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}
The first paragraph is now indented entirely by the given value. Both commands are TeX primitives.


Best regards
Thorsten¹
nieproszenieja
Posts: 9
Joined: Tue Jul 08, 2008 10:25 pm

Indent full paragraph

Post by nieproszenieja »

gmedina wrote:

Code: Select all

\documentclass{article}
\usepackage{lipsum}

\begin{document}
%(some code....)
\hangindent=1cm
\lipsum[1]

\end{document}
Replace 1cm with \parindent (\hangindent=\parindent), the result will be quite the same as yours.
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.
orey
Posts: 1
Joined: Sat Aug 11, 2012 9:43 am

Indent full paragraph

Post by orey »

I had the problem in a resume where I did not want to have the spaces generated by the list solution.
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.}
Advantage is that it is justified.
Post Reply