Changes

Jump to navigation Jump to search
2,940 bytes removed ,  08:11, 12 April 2019
no edit summary
In plain TeX, controlling indentation is simple: The user sets a value for <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.
So, understanding indentation Indentation in plain TeX and LaTeX boils down to thisConTeXt are a bit different: set a value for <tt>parindent</tt>, and start a new paragraph (i.e., leave an empty line) whenever you want indentation. For example, LaTeX usually it mostly does not indent rely on the first line after a sectioning command. If you want presence of blank lines, but uses {{cmd|setupindenting}} to indent the first line after a sectioning command you use manage general indentation, the <code>indentfirstindentnext=yes/no/auto</code> package (which is part of the required LaTeX bundle). If you want key on environments to indent the paragraph enable/disable indentation after an environmentthem, you leave a blank line after the end of the environment; if you do not want and {{cmd|indentation}} and {{cmd|noindentation}} to indent after the end of manually force/disable an environment, you do not leave a blank line. It takes a while to get used to, but the rules are easy to remember and eventually you do not need to even think about indentation; it becomes a matter of habit.
Indentations in ConTeXt are a bit different; and sometimes difficult to understand. In this article I hope to explain how ConTeXt does indentations. First, let's understand why ConTeXt does indentations differently; why does it not simply follow the time-tested approach of plain TeX and LaTeX? The way I understand itcommands {{cmd|indent}}, the reason is that Hans Hagen{{cmd|noindent}}, the author of ConTeXt{{cmd|indenting}}, prefers ''spaced out'' markup &mdash; surrounding each environment by empty lines &mdash; which makes it easy to see where an environment starts and ends while reading the source file. However{{cmd|noindenting}} are present for historical reasons, this style means that the 'indentation after empty lines' paradigm of plain TeX and LaTeX cannot but should not be used for indentations. SoEspecially, ConTeXt provides an alternative. As they should not be confused with other things in ConTeXt, this alternative is consistent {{cmd|indentation}} and easy to configure; but if you are used to other TeX formats it takes some time to get comfortable with it. {{cmd|noindentation}}
= The basics =
== 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 <tt>{{cmd|setupindenting}}<tt>[...]</tt>. There are three types of keys for this command:
* <code>'''To enable indenting:no''' <code>never</code> or <code>always</code>, (equivalently, <code>no</code> or <code>yes</code>), The default is '''<code>never<: turn indentation on/code>''off' * '''To specify when to indent:''': <code>odd</code> or <code>even</code>, and <code>first</code> or <code>next</code>. The default is ''none'<code>first</code>'small medium big '' * '''To specify how much to indent:'dimension'' <code>none</code>, : size of indents* <code>small</code>, <code>medium</code>, <code>big</code>, or a specific dimension. <code>small</code> corresponds to 1em, <code>medium</code> to 1.5em, and <code>big</code> to 2em. The default is ''first''<code>nonenext</code>'''.  Suppose we want to indent all paragraphs by 20pt: we can use<texcode>\setupindenting[20pt, yes]</texcode>  which is equivalent ot <texcode>\setupindenting[20pt, yes, turn indentation of first]<paragraph on/texcode> This is what one typically uses in a documentoff. The other keys are needed only for special cases (like typesetting quotations and verses). In particular, the most commonly used keys are * Can be overridden by environments with <code>indentnext=yes</code> enable indenting* <code>no</code> disable indenting* <code>toggleauto</code> toggle the indenting state (if indenting was enabled, disable it and vice-versa).* <code>oddeven</code> indents every : indent odd paragraph* <code>even</code> indents every even paragraphlines in \obeylines scopes* <code>firstnormal</code> indents all paragraphs, including the first paragraph* <code>next</code> '': what does not'' indent the first paragraph, but indents every subsequent paragraph* <code>reset</code> reset all settings to their default values. This disable indenting, sets the indenting amount to <code>none</code>, disables <code>odd</code> or <code>even</code> indenting, and sets indenting method to <code>first</code>.this do?
== 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.
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>, and <code>auto</code>. If <code>indentnext=yes</code> then declares the first paragraph after the end of following the environment is always should never be indented; if .* <code>indentnext=noauto</code> then the next paragraph is never indented; if declares <code>indentnext=auto</code> then the next paragraph is 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.
Let us provide a couple of Some examples. Suppose we do not want paragraphs after itemize to be indented; then we can say :
<texcode>
% Do not indent paragraphs after \stopitemize
\setupitemgroup[itemize][indentnext=no]
</texcode>
 
If we want paragraphs after section heads to be indented, we can say
<texcode>% indent paragraphs after section heads
\setuphead[section][indentnext=yes]
</texcode>
 
If we want the paragraphs after all sectioning heads to be indented, we can say
 
<texcode>
\setupheads[indentnext=yes]
</texcode>
If we want % indent the paragraphs after formulas to be indented only if we leave a blank space after them, we can sayall sectioning heads \setupheads[indentnext=yes]
<texcode>% indent paragraphs after formulas if there is a blank space in between\setupformulas[indentnext=auto]
</texcode>
== Setting up indentation inside environments ==
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 values arguments as the arguments of {{cmd|setupindenting}} commanddoes. For An example, if we set <texcode>\using {{cmd|setupitemgroup[itemize][indenting={40pt,next}]</texcode> then the following }:
<context source="yes" text="gives">
</context>
= Manual indentation = "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 == 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. Plain TeX (and LaTeX) provide the This is done with {{cmd|indentindentation}} and {{cmd|noindentnoindentation}} . The Plain TeX (and LaTeX) commands for explicitly indenting <tt>\indent</tt> and preventing indenting of a paragraph. These commands <tt>\noindent</tt> are defined in ConTeXt , but are not hooked into the ConTeXt indentation mechanism. Instead, ConTeXt provides {{cmd|indentation}} and {{cmd|noindentation}} which achieve the same effect.
Suppose the default setup for an article is
\startitemize[n]
\item A dummy listwith \type{indentnext=no}... \item To check ...to test the \typetex{\indent}command
\stopitemize
\indent This paragraph is not indented. The , because \typetex{\indent} command does not work here.
\startitemize[n]
\item Another dummy listwith \type{indentnext=no}... \item To check ...to test the \typetex{\indentation}command
\stopitemize
\indentation This paragraph will be indented , because we used \typetex{\indentation} instead.
</context>
= Beware of typos = ConTeXt defines two more commands not commonly used: {{cmd|indentingGetting started navbox}} and {{cmd|noindenting}}. {{cmd|indenting}} is similar to {{cmd|setupindenting}} and is provided for backward compatibility; {{cmd|noindenting}} is equivalent to {{cmd|setupindenting[no]}}. Unfortunately, these commands sound very similar to {{cmd|indentation}} and {{cmd|noindentation}}, thus can be easily used by mistake. If you happen to write {{cmd|noindenting}} instead of {{cmd|noindentation}} in a document, it can take a while to debug.
105

edits

Navigation menu