Changes

Jump to navigation Jump to search
2,383 bytes removed ,  20:15, 8 June 2020
m
no edit summary
In plain TeX, controlling indentation is simple: The user sets a value for < [[Visuals]]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.
In plain TeXIndentation in ConTeXt are a bit different: it mostly does not rely on the presence of blank lines, controlling but uses {{cmd|setupindenting}} to manage general indentation is simple: The user sets a value for, the <cmdcode>parindentindentnext=yes/no/auto</cmdcode>key on environments to enable/disable indentation after them, and each new paragraph is indented by that value, unlessexplicitly begun with <{{cmd>noindent</|indentation}} and {{cmd>. Environments can provide a<cmd>noindent<|noindentation}} to manually force/cmd> at the end of their definitions, and if the user wants tooverrule that, he can add disable an explicit <cmd>indent</cmd> at the beginning of the nextparagraph. For the most part, LaTeX follows the same conventionindentation.
SoThe commands {{cmd|indent}}, understanding indentation in plain TeX and LaTeX boils down to this: set avalue for <{{cmd>parindent</|noindent}}, {{cmd>|indenting}}, and start a new paragraph (i.e.{{cmd|noindenting}} are present for historical reasons, leave an emptyline) whenever you want indentation. For example, LaTeX usually does but should not indentthe first line after a sectioning command. If you want to indent the first lineafter a sectioning command you use the <code>indentfirst</code> package (whichis part of the required LaTeX bundle)be used. If you want to indent the paragraph afteran environmentEspecially, you leave a blank line after the end of the environment; if youdo they should not want to indent after the end of an environment, you do not leave a blankline. It takes a while to get used to, but the rules are easy to remember be confused with {{cmd|indentation}} andeventually you do not need to even think about indentation; it becomes a matterof habit.{{cmd|noindentation}}
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 it, the reason is that Hans Hagen, the author of ConTeXt, 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, this style means that the 'indentation after
empty lines' paradigm of plain TeX and LaTeX cannot be used for indentations.
So, ConTeXt provides an alternative. As with other things in ConTeXt, this
alternative is consistent and easy to configure; but if you are used to other
TeX formats it takes some time to get comfortable with it.
 
= The basics =
== Setting up indentation for the whole document ==
Indentation involves two things: when to indent, and how much to indent. InConTeXt, these can be specified using {{cmd|setupindenting}}<cmdtt>setupindenting[...]</cmdtt>. Thereare two three types of keys for this command: * '''To specify ''when to indent'':''' <code>never</code> or <code>always</code>, (equivalently, <code>no</code> or <code>yes</code>), <code>odd</code> or <code>even</code>, and <code>first</code> or <code>next</code>. * '''To specify ''how much to indent'':''' <code>none</code>, <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.  Suppose we want to indent all paragraphs by 20pt: we can use<texcode>\setupindenting[20pt, yes]</texcode>  This is what one typically uses in a document. The other keys are needed onlyfor special cases (like typesetting quotations and verses). In particular:
* <code>odd''no'' yes</code> indents every odd paragraph: turn indentation on/off'* <code>even''none'' small medium big ''dimension''</code> : size of indents every even paragraph* <code>''first'' next</code> indents the : turn indentation of first paragraphon/off. Can be overridden by environments with <code>indentnext=yes/no/auto</code>.* <code>nextodd even</code>: indent odd/even lines in \obeylines scopes* <code>normal</code> ''does not'' : the globally defined size of indent . Useful when used as the first paragraph, but indents every subsequent paragrahvalues of the `indenting` key of different environments.
== Setting up indentation after an environment ==
<{{cmd>|setupindenting</cmd> }} does not take care of indenting after environments,such as ConTeXt's itemizes, enumerations, definitions, formulas and floats. Italso does not take care of indenting after heads such as chapters, sections, andsubsections. The setup command of these environments provides an'''<code>indentnext</code>''' key to configure the indentation behaviour afterthe environment. The <code>indentnext</code> key can take one of three values:<code>yes</code>, <code>no</code>, and <code>auto</code>. If<code>indentnext=yes</code> then the paragraph after the end of the environmentis always indented; if <code>indentnext=no</code> then the next paragraph isnever indented; if <code>indentnext=auto</code> then the next paragraph isindented only if there is a blank space after the environment. Setting<code>indentnext=auto</code> is equivalent to the default plain TeX and LaTeXbehaviour.
Let us provide a couple The setup command of examplesthese 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. Suppose we do not want paragraphs afteritemize to * <code>auto</code> declares <code>indentnext=auto</code> the next paragraph should be indented; then we can sayonly 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>
% 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 % indent the paragraphs after all sectioning heads to beindented, we can say\setupheads[indentnext=yes]
<texcode>\setupheads[indentnext=yes]</texcode> If we want % indent paragraphs after formulas to be indented only if weleave there is a blank space after them, we can say <texcode>in between\setupformulas[indentnext=auto]
</texcode>
== Setting up indentation inside environments ==
There is one case that is not taken care of by <{{cmd>|setupindenting</cmd> }} and the<code>indentnext</code> key: indentation of paragraphs inside multi-paragraphenvironments such as itemizes, descriptions, and enumerations. By defaultConTeXt does not indent such paragraphs. The setup commands of theseenvironments provides an '''<code>indenting=</code>''' key to configure the indentationbehaviour of paragraphs inside these environments. This key takes the samevalues arguments as the arguments of <{{cmd>|setupindenting</cmd> }} commanddoes. For An example, if we setusing {{cmd|setupitemgroup}}:
<texcodecontext source="yes" text="gives">\setupitemgroupsetuppapersize[itemizeA5][indenting={40pt,yes}]</texcode>
then the following : <context source="\setupindenting[medium,yes" text="gives" scale="0.8">]\setupitemgroup[itemize][indenting={40pt,yesnext}]
\startitemize
\item This is an example of a multi|-|paragraph
</context>
{{note|type=attention|1=Indentation inside itemize works differently in MkIV: <code>indenting"indentnext=auto" demo ={40pt,yes}</code> also indents the first line! To get the visual output shown above in MkIV, use <code>indenting={40pt,'''next'''}</code>.}}
<context source = Manual indentation "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 whichcannot be taken care of by automatic indentation, and we have to tell ConTeXthow to indent. This is done with {{cmd|indentation}} and {{cmd|noindentation}}. The Plain TeX (and LaTeX) provide the commands <cmdtt>\indent</cmdtt> and <cmdtt>\noindent</cmdtt>commands for explicitly indenting and preventing indenting of a paragraph. Thesecommands are defined in ConTeXt , but are not hooked into the ConTeXtindentation mechanism. Instead, ConTeXt provides <cmd>indentation</cmd> and<cmd>noindentation</cmd> which achieve the same effect.
Suppose the default setup for an article is
</texcode>
Now, if we want to indent after an itemize, starting the next paragraphwith <{{cmd>|indent</cmd> }} does not work; to get indentation we have to say<{{cmd>|indentation</cmd>}}. For example, <context source="yes" text="gives">\setuppapersize[A5]
<context source="yes" text="gives" scale="0.8">
\setupindenting [big,yes]
\setupitemgroup [itemize] [indentnext=no]
 
\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[[Category:<cmd>indenting</cmd> and <cmd>noindenting</cmd>. <cmd>indenting</cmd> is similar to<cmd>setupindenting</cmd> and is provided for backward compatibility;<cmd>noindenting</cmd> is equivalent to<cmd>setupindenting[noBasics]]</cmd>. Unfortunately, these commands sound verysimilar to <cmd>indentation</cmd> and <cmd>noindentation</cmd>, thus can be easily used by mistake. If you happen to write <cmd>noindenting</cmd> instead of<cmd>noindentation</cmd> in a document, it can take a while to debug.

Navigation menu