Changes

Jump to navigation Jump to search
2,177 bytes removed ,  21:22, 17 July 2014
m
no edit summary
< [[Visuals]]
In plain TeX, controlling indentation is simple: The user sets a value for<cmdtt>parindent</cmdtt>, and each new paragraph is indented by that value, unlessexplicitly begun with <cmdtt>noindent</cmdtt>. Environments can provide a<cmdtt>noindent</cmdtt> at the end of their definitions, and if the user wants tooverrule that, he can add an explicit <cmdtt>indent</cmdtt> at the beginning of the nextparagraph. 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 avalue for <cmd>parindent</cmd>, and start a new paragraph (i.e., leave an emptyline) whenever you want indentation. For example, LaTeX usually it mostly does not indentrely on the first line after a sectioning command. If you want presence of blank lines, but uses {{cmd|setupindenting}} to indent the first lineafter a sectioning command you use manage general indentation, the <code>indentfirstindentnext=yes/no/auto</code> package (whichis part of the required LaTeX bundle). If you want key on environments to indent the paragraph enable/disable indentation afteran environmentthem, you leave a blank line after the end of the environment; if youdo not want and {{cmd|indentation}} and {{cmd|noindentation}} to indent after the end of manually force/disable an environment, you do not leave a blankline. It takes a while to get used to, but the rules are easy to remember andeventually you do not need to even think about indentation; it becomes a matterof habit.
Indentations in ConTeXt are a bit different; and sometimes difficult tounderstand. In this article I hope to explain how ConTeXt does indentations.FirstThe commands {{cmd|indent}}, let's understand why ConTeXt does indentations differently; why does itnot simply follow the time{{cmd|-noindent}}, {{cmd|tested approach of plain TeX and LaTeX? The way Iunderstand it, the reason is that Hans Hagen, the author of ConTeXtindenting}}, prefers''spaced out'' markup &mdash; surrounding each environment by empty lines&mdash; which makes it easy to see where an environment starts and ends whilereading the source file. However{{cmd|noindenting}} are present for historical reasons, this style means that the 'indentation afterempty 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, thisalternative is consistent {{cmd|indentation}} and easy to configure; but if you are used to otherTeX 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. InConTeXt, these can be specified using {{cmd|setupindenting}}<cmdtt>setupindenting[...]</cmdtt>. Thereare two three types of keys for this command:
* <code>''no''yes</code>: turn indentation on/off'* <code>'To specify 'none'when to indent'small medium big ':'dimension'' <code>never</code> or : size of indents* <code>always''first'' next</code>, (equivalently, : turn indentation of first paragraph on/off. Can be overridden by environments with <code>indentnext=yes/no</code> or <code>yesauto</code>), .* <code>odd</code> or <code>even</code>, and <code>first<: indent odd/code> or even lines in \obeylines scopes* <code>nextnormal</code>.: what does this do?
* '''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.== 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.
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).   <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>declares the first paragraph following the environment should always be indented. If* <code>indentnext=yesno</code> then declares the first paragraph after the end of following the environmentshould never be indented.is always indented; if * <code>indentnext=noauto</code> then the next paragraph isnever indented; if declares <code>indentnext=auto</code> then the next paragraph isshould 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 LaTeXbehaviour.  Let us provide a couple of examples. Suppose we do not want paragraphs afteritemize to be indented; then we can say
Some examples:
<texcode>
% Do not indent paragraphs after \stopitemize
\setupitemgroup[itemize][indentnext=no]
</texcode>
If we want % indent paragraphs after section heads to be indented, we can say <texcode>
\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>
There is one case that is not taken care of by <cmd>setupindenting</cmd> and the<code>indentnext</code> key: == Setting up 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 as the arguments of <cmd>setupindenting</cmd> command. For example, if we set==
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 <texcodecode>\setupitemgroup[itemize][indenting={40pt,yes}]</texcodecode>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}}:
then the following :<context source="yes" text="gives">\setuppapersize[A5]
<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>
== 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:<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[no]</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.{{Getting started navbox}}

Navigation menu