LaTeX forum ⇒ GeneralIndent full paragraph

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

Indent full paragraph

Postby Aurora » Tue Sep 04, 2007 8:16 pm

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!

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
Location: Colombia

Postby gmedina » Tue Sep 04, 2007 8:52 pm

Aurora wrote:Maybe I can create a quote-like environment with left-only indent!?


Sure you can. Try something like the following
  1. \newenvironment{myindentpar}[1]%
  2. {\begin{list}{}%
  3. {\setlength{\leftmargin}{#1}}%
  4. \item[]%
  5. }
  6. {\end{list}}

And use it like this:
  1. \begin{myindentpar}{3cm}
  2. text text text...
  3. \end{myindentpar}
1,1,2,3,5,8,13,21,34,55,89,144,233,...

Link:
BBcode:
HTML:
Hide post links
Show post links

Aurora
Posts: 17
Joined: Thu Jun 28, 2007 3:42 pm

Postby Aurora » Tue Sep 04, 2007 9:25 pm

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.

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
Location: Colombia

Postby gmedina » Tue Sep 04, 2007 9:43 pm

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,...

Link:
BBcode:
HTML:
Hide post links
Show post links

nieproszenieja
Posts: 9
Joined: Tue Jul 08, 2008 10:25 pm
Location: Wrocław, Poland

Postby nieproszenieja » Tue Jul 08, 2008 10:59 pm

There is a better way to do this - command ' \hangindent=length ' (e.g. \hangindent=1cm, etc.) inside paragraph do the trick.

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
Location: Colombia

Postby gmedina » Tue Jul 08, 2008 11:07 pm

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:
  1. \documentclass{article}
  2. \usepackage{lipsum}
  3.  
  4. \newenvironment{myindentpar}[1]%
  5. {\begin{list}{}%
  6. {\setlength{\leftmargin}{#1}}%
  7. \item[]%
  8. }
  9. {\end{list}}
  10.  
  11. \begin{document}
  12.  
  13. \lipsum[1]
  14.  
  15. \begin{myindentpar}{1cm}
  16. \lipsum[1]
  17. \end{myindentpar}
  18.  
  19. \hangindent=1cm
  20. \lipsum[1]
  21.  
  22. \end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Tue Jul 08, 2008 11:16 pm

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.
  1. \documentclass[11pt,a4paper]{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[latin1]{inputenc}
  4. \usepackage[english]{babel}
  5. \usepackage[bindingoffset=1cm,centering,includeheadfoot,margin=2cm]{geometry}
  6. \usepackage{blindtext}
  7. \usepackage{txfonts}
  8.  
  9. \parindent0em
  10.  
  11. \begin{document}
  12. \hangindent2em
  13. \hangafter=0
  14. \blindtext
  15.  
  16. \medskip
  17. \blindtext
  18. \end{document}

The first paragraph is now indented entirely by the given value. Both commands are TeX primitives.


Best regards
Thorsten¹
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses

Link:
BBcode:
HTML:
Hide post links
Show post links

nieproszenieja
Posts: 9
Joined: Tue Jul 08, 2008 10:25 pm
Location: Wrocław, Poland

Postby nieproszenieja » Wed Jul 09, 2008 1:34 am

gmedina wrote:
  1. \documentclass{article}
  2. \usepackage{lipsum}
  3.  
  4. \begin{document}
  5. %(some code....)
  6. \hangindent=1cm
  7. \lipsum[1]
  8.  
  9. \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.

Link:
BBcode:
HTML:
Hide post links
Show post links

orey
Posts: 1
Joined: Sat Aug 11, 2012 9:43 am

Postby orey » Sat Aug 11, 2012 9:51 am

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.
  1. %===============Variables
  2. \def \constzeroindent {0cm}
  3. \def \constfirstindent {0.5cm}
  4. \def \constsecondindent {1cm}
  5.  
  6. %===============Macros
  7. \newenvironment{mycustomindent}[1]
  8. {\setlength{\parindent}{#1}}
  9. {\setlength{\parindent}{\constzeroindent}}
  10.  
  11. \newcommand{\myindentedpar}[1]{
  12. \begin{mycustomindent}{\constsecondindent}
  13. \begin{tabular}{@{}p{17cm}@{}}
  14. #1 \\
  15. \end{tabular}
  16. \end{mycustomindent}}
  17.  
  18. %===============Use
  19. \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.

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “General”

Who is online

Users browsing this forum: Bing [Bot] and 7 guests