Difference between revisions of "Indentation"
m (typo) |
m |
||
(14 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
− | < | + | In plain TeX, controlling indentation is accomplished by configuring <tt>parindent</tt>, and each new paragraph is indented by that value, unless explicitly begun with <tt>noindent</tt>. Environments can provide a <tt>noindent</tt> at the end of their definitions, and if the user wants to overrule that, he can add an explicit <tt>indent</tt> at the beginning of the next paragraph. For the most part, LaTeX follows the same convention. |
− | + | Indentation in ConTeXt is a bit different: it mostly does not rely on the presence of blank lines, but uses {{cmd|setupindenting}} to manage general indentation, the <code>indentnext=yes/no/auto</code> key on environments to enable/disable indentation after them, and {{cmd|indentation}} and {{cmd|noindentation}} to manually force/disable an indentation. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | The commands {{cmd|indent}}, {{cmd|noindent}}, {{cmd|indenting}}, and {{cmd|noindenting}} are present for historical reasons, but should not be used. Especially, they should not be confused with {{cmd|indentation}} and {{cmd|noindentation}} | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Setting up indentation for the whole document == | == Setting up indentation for the whole document == | ||
− | Indentation involves two things: when to indent, and how much to indent. In | + | Indentation involves two things: when to indent, and how much to indent. In ConTeXt, these can be specified using {{cmd|setupindenting}}<tt>[...]</tt>. There are three types of keys for this command: |
− | ConTeXt, these can be specified using < | ||
− | are three types of keys for this command: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | * <code>yes</code> | + | * <code>''no'' yes</code>: turn indentation on/off' |
− | * <code> | + | * <code>''none'' small medium big ''dimension''</code>: size of indents |
− | * <code> | + | * <code>''first'' next</code>: turn indentation of first paragraph on/off. Can be overridden by environments with <code>indentnext=yes/no/auto</code>. |
− | + | * <code>odd even</code>: indent odd/even lines in \obeylines scopes | |
− | * <code>even</code> | + | * <code>normal</code>: the globally defined size of indent. Useful when used as the values of the `indenting` key of different environments. |
− | * <code> | ||
− | |||
− | |||
== Setting up indentation after an environment == | == Setting up indentation after an environment == | ||
− | + | {{cmd|setupindenting}} does not take care of indenting after environments, such as ConTeXt's itemizes, enumerations, definitions, formulas and floats. It also does not take care of indenting after heads such as chapters, sections, and subsections. | |
− | such as ConTeXt's itemizes, enumerations, definitions, formulas and floats. It | ||
− | also does not take care of indenting after heads such as chapters, sections, and | ||
− | subsections | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | The setup command of these environments provides an '''<code>indentnext</code>''' key to configure the indentation behaviour after the environment. The <code>indentnext</code> key can take one of three values: | |
− | + | * <code>yes</code> declares the first paragraph following the environment should always be indented. | |
+ | * <code>no</code> declares the first paragraph following the environment should never be indented. | ||
+ | * <code>auto</code> declares <code>indentnext=auto</code> the next paragraph should be indented only if there is a blank space after the environment. Setting <code>indentnext=auto</code> is equivalent to the default plain TeX and LaTeX behaviour. | ||
+ | Some examples: | ||
<texcode> | <texcode> | ||
+ | % Do not indent paragraphs after \stopitemize | ||
\setupitemgroup[itemize][indentnext=no] | \setupitemgroup[itemize][indentnext=no] | ||
− | |||
− | |||
− | |||
− | + | % indent paragraphs after section heads | |
\setuphead[section][indentnext=yes] | \setuphead[section][indentnext=yes] | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | % indent the paragraphs after all sectioning heads | |
− | + | \setupheads[indentnext=yes] | |
− | + | % indent paragraphs after formulas if there is a blank space in between | |
− | \setupformulas[indentnext=auto] | + | \setupformulas[indentnext=auto] |
</texcode> | </texcode> | ||
== Setting up indentation inside environments == | == Setting up indentation inside environments == | ||
− | There is one case that is not taken care of by | + | There is one case that is not taken care of by {{cmd|setupindenting}} and the <code>indentnext</code> key: indentation of paragraphs inside multi-paragraph environments such as itemizes, descriptions, and enumerations. By default ConTeXt does not indent such paragraphs. The setup commands of these environments provides an <code>indenting=</code> key to configure the indentation behaviour of paragraphs inside these environments. This key takes the same arguments as the {{cmd|setupindenting}} command does. An example using {{cmd|setupitemgroup}}: |
− | <code>indentnext</code> key: indentation of paragraphs inside multi-paragraph | ||
− | environments such as itemizes, descriptions, and enumerations. By default | ||
− | ConTeXt does not indent such paragraphs. The setup commands of these | ||
− | environments provides an | ||
− | behaviour of paragraphs inside these environments. This key takes the same | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | <context source="yes" text="gives"> | |
+ | \setuppapersize[A5] | ||
− | |||
\setupindenting[medium,yes] | \setupindenting[medium,yes] | ||
\setupitemgroup[itemize][indenting={40pt,next}] | \setupitemgroup[itemize][indenting={40pt,next}] | ||
Line 141: | Line 57: | ||
</context> | </context> | ||
− | + | == "indentnext=auto" demo == | |
+ | |||
+ | <context source = "yes" text="gives:"> | ||
+ | \setupindenting[medium,yes] | ||
+ | \setupitemize[indentnext=auto] | ||
+ | |||
+ | \startitemize | ||
+ | \item One | ||
+ | \stopitemize | ||
+ | |||
+ | This paragraph should be indented - due to the blank line after \type{\stopitemize}. | ||
+ | |||
+ | \startitemize | ||
+ | \item Two | ||
+ | \stopitemize | ||
+ | This paragraph should not be indented. | ||
+ | </context> | ||
− | = Manual indentation = | + | == Manual indentation == |
− | No matter how careful we are with all the settings, there are some cases which | + | No matter how careful we are with all the settings, there are some cases which cannot be taken care of by automatic indentation, and we have to tell ConTeXt how to indent. This is done with {{cmd|indentation}} and {{cmd|noindentation}}. The Plain TeX (and LaTeX) commands <tt>\indent</tt> and <tt>\noindent</tt> are defined in ConTeXt, but are not hooked into the indentation mechanism. |
− | cannot be taken care of by automatic indentation, and we have to tell ConTeXt | ||
− | how to indent. Plain TeX (and LaTeX) | ||
− | |||
− | |||
− | indentation mechanism | ||
− | |||
Suppose the default setup for an article is | Suppose the default setup for an article is | ||
Line 158: | Line 84: | ||
</texcode> | </texcode> | ||
− | Now, if we want to indent after an itemize, starting the next paragraph | + | Now, if we want to indent after an itemize, starting the next paragraph with {{cmd|indent}} does not work; to get indentation we have to say {{cmd|indentation}}. For example, |
− | with | + | |
− | + | <context source="yes" text="gives"> | |
+ | \setuppapersize[A5] | ||
− | |||
\setupindenting [big,yes] | \setupindenting [big,yes] | ||
\setupitemgroup [itemize] [indentnext=no] | \setupitemgroup [itemize] [indentnext=no] | ||
+ | |||
\startitemize[n] | \startitemize[n] | ||
− | \item A dummy list | + | \item A dummy list with \type{indentnext=no}... |
− | \item | + | \item ...to test the \tex{indent} command |
\stopitemize | \stopitemize | ||
− | \indent This paragraph is not indented | + | \indent This paragraph is not indented, because \tex{indent} does not work. |
− | \ | ||
\startitemize[n] | \startitemize[n] | ||
− | \item Another dummy list | + | \item Another dummy list with \type{indentnext=no}... |
− | \item | + | \item ...to test the \tex{indentation} command |
\stopitemize | \stopitemize | ||
− | \indentation This paragraph will be indented | + | \indentation This paragraph will be indented, because we used \tex{indentation}. |
− | because we used \ | ||
</context> | </context> | ||
− | |||
− | + | [[Category:Basics]] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 06:32, 16 April 2021
In plain TeX, controlling indentation is accomplished by configuring parindent, and each new paragraph is indented by that value, unless explicitly begun with noindent. Environments can provide a noindent at the end of their definitions, and if the user wants to overrule that, he can add an explicit indent at the beginning of the next paragraph. For the most part, LaTeX follows the same convention.
Indentation in ConTeXt is a bit different: it mostly does not rely on the presence of blank lines, but uses \setupindenting to manage general indentation, the indentnext=yes/no/auto
key on environments to enable/disable indentation after them, and \indentation and \noindentation to manually force/disable an indentation.
The commands \indent, \noindent, \indenting, and \noindenting are present for historical reasons, but should not be used. Especially, they should not be confused with \indentation and \noindentation
Setting up indentation for the whole document
Indentation involves two things: when to indent, and how much to indent. In ConTeXt, these can be specified using \setupindenting[...]. There are three types of keys for this command:
no yes
: turn indentation on/off'none small medium big dimension
: size of indentsfirst next
: turn indentation of first paragraph on/off. Can be overridden by environments withindentnext=yes/no/auto
.odd even
: indent odd/even lines in \obeylines scopesnormal
: the globally defined size of indent. Useful when used as the values of theindenting
key of different environments.
Setting up indentation after an environment
\setupindenting does not take care of indenting after environments, such as ConTeXt's itemizes, enumerations, definitions, formulas and floats. It also does not take care of indenting after heads such as chapters, sections, and subsections.
The setup command of these environments provides an indentnext
key to configure the indentation behaviour after the environment. The indentnext
key can take one of three values:
yes
declares the first paragraph following the environment should always be indented.no
declares the first paragraph following the environment should never be indented.auto
declaresindentnext=auto
the next paragraph should be indented only if there is a blank space after the environment. Settingindentnext=auto
is equivalent to the default plain TeX and LaTeX behaviour.
Some examples:
% Do not indent paragraphs after \stopitemize \setupitemgroup[itemize][indentnext=no] % indent paragraphs after section heads \setuphead[section][indentnext=yes] % indent the paragraphs after all sectioning heads \setupheads[indentnext=yes] % indent paragraphs after formulas if there is a blank space in between \setupformulas[indentnext=auto]
Setting up indentation inside environments
There is one case that is not taken care of by \setupindenting and the indentnext
key: indentation of paragraphs inside multi-paragraph environments such as itemizes, descriptions, and enumerations. By default ConTeXt does not indent such paragraphs. The setup commands of these environments provides an indenting=
key to configure the indentation behaviour of paragraphs inside these environments. This key takes the same arguments as the \setupindenting command does. An example using \setupitemgroup:
\setuppapersize[A5] \setupindenting[medium,yes] \setupitemgroup[itemize][indenting={40pt,next}] \startitemize \item This is an example of a multi|-|paragraph item inside an itemize environment. This second paragraph is indented by 40pt (double the normal indentation). \stopitemize
gives
"indentnext=auto" demo
\setupindenting[medium,yes] \setupitemize[indentnext=auto] \startitemize \item One \stopitemize This paragraph should be indented - due to the blank line after \type{\stopitemize}. \startitemize \item Two \stopitemize This paragraph should not be indented.
gives:
Manual indentation
No matter how careful we are with all the settings, there are some cases which cannot be taken care of by automatic indentation, and we have to tell ConTeXt how to indent. This is done with \indentation and \noindentation. The Plain TeX (and LaTeX) commands \indent and \noindent are defined in ConTeXt, but are not hooked into the indentation mechanism.
Suppose the default setup for an article is
\setupitemgroup [itemize] [indentnext=no]
Now, if we want to indent after an itemize, starting the next paragraph with \indent does not work; to get indentation we have to say \indentation. For example,
\setuppapersize[A5] \setupindenting [big,yes] \setupitemgroup [itemize] [indentnext=no] \startitemize[n] \item A dummy list with \type{indentnext=no}... \item ...to test the \tex{indent} command \stopitemize \indent This paragraph is not indented, because \tex{indent} does not work. \startitemize[n] \item Another dummy list with \type{indentnext=no}... \item ...to test the \tex{indentation} command \stopitemize \indentation This paragraph will be indented, because we used \tex{indentation}.
gives