Changes

Jump to navigation Jump to search
2,670 bytes removed ,  08:11, 12 April 2019
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.First, let's understand why ConTeXt does indentations differently; why does itnot simply follow the time-tested approach of plain TeX and LaTeX? The way Iunderstand 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 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>'''To specify ''when to indentno'':''' <code>never</code> or <code>always</code>, (equivalently, <code>no</code> or <code>yes</code>), <code>odd<: turn indentation on/code> or <code>evenoff'* </code>, and <code>first</code> or <code>next</code>. * ''none'To specify ''how much to indentsmall medium big '':dimension''' <code>none</code>, : size of indents* <code>small''first'' next</code>, <code>medium</code>, <code>big<: turn indentation of first paragraph on/code>, or a specific dimensionoff. <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 Can be overridden by 20pt: we can use<texcode>\setupindenting[20pt, yes]</texcode>  This is what one typically uses in a document. The other keys are needed only for special cases (like typesetting quotations and verses). In particular, the most commonlysused keys are * 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 the first paragraph* <code>next</code> '': what does not'' indent the first paragraph, but indents every subsequent paragrahthis do?
== 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:<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}}
105

edits

Navigation menu