Changes

Jump to navigation Jump to search
1,801 bytes removed ,  08:11, 12 April 2019
no edit summary
In plain TeX, controlling indentation is simple: The user sets a value for<cmd>parindent</cmd>, and each new paragraph is indented by that value, unlessexplicitly begun with <cmd>noindent</cmd>. Environments can provide a<cmd>noindent</cmd> at the end of their definitions, and if the user wants tooverrule that, he can add an explicit <cmd>indent</cmd> at the beginning of the nextparagraph. For the most part, LaTeX follows the same convention.[[Visuals]]
SoIn plain TeX, understanding controlling indentation in plain TeX and LaTeX boils down to thisis simple: set The user sets avalue for <cmdtt>parindent</cmdtt>, and start a each new paragraph (i.e.is indented by that value, leave an emptyline) whenever you want indentationunless explicitly begun with <tt>noindent</tt>. For example, LaTeX usually does not indentthe first line after a sectioning command. If you want to indent the first lineafter Environments can provide a sectioning command you use the <codett>indentfirstnoindent</codett> package (whichis part of the required LaTeX bundle). If you want to indent the paragraph afteran environment, you leave a blank line after at the end of their definitions, and if the environment; if youdo not want user wants to overrule that, he can add an explicit <tt>indent after </tt> at the end beginning of an environment, you do not leave a blanklinethe next paragraph. It takes a while to get used toFor the most part, but LaTeX follows the rules are easy to remember andeventually you do not need to even think about indentation; it becomes a matterof habitsame convention.
Indentations Indentation in ConTeXt are a bit different; and sometimes difficult tounderstand. In this article I hope to explain how ConTeXt : it mostly does indentations.First, let's understand why ConTeXt does indentations differently; why does itnot simply follow rely on the time|-|tested approach presence of plain TeX and LaTeX? The way Iunderstand itblank lines, the reason is that Hans Hagenbut uses {{cmd|setupindenting}} to manage general indentation, the author of ConTeXt, prefers''spaced out'' markup &mdash; surrounding each environment by empty lines&mdash; which makes it easy <code>indentnext=yes/no/auto</code> key on environments to see where an environment starts and ends whilereading the source file. However, this style means that the 'enable/disable indentation afterempty lines' paradigm of plain TeX them, and LaTeX cannot be used for indentations.So, ConTeXt provides an alternative. As with other things in ConTeXt, thisalternative is consistent {{cmd|indentation}} and easy {{cmd|noindentation}} to configure; but if you are used to otherTeX formats it takes some time to get comfortable with itmanually force/disable an indentation.
= The basics =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}}
Indentation involves two things: when to indent, and how much to indent. InConTeXt, these can be specified using <cmd>setupindenting[...]</cmd>. Thereare two types of keys == Setting up indentation for this command:the whole document ==
* '''To specify ''Indentation involves two things: when to indent'':''' <code>never</code> or <code>always</code>, (equivalentlyand how much to indent. In ConTeXt, these can be specified using {{cmd|setupindenting}}<codett>no</code> or <code>yes</code>), <code>odd</code> or <code>even</code>, and <code>first</code> or <code>next[...]</codett>.There are three types of keys for this command:
* <code>'''To specify ''how much to indent'':'no'' yes</code>none<: turn indentation on/code>, off'* <code>''none'' smallmedium big ''dimension''</code>, : size of indents* <code>medium''first'' next</code>, : turn indentation of first paragraph on/off. Can be overridden by environments with <code>bigindentnext=yes/no/auto</code>, or a specific dimension. * <code>smallodd even</code> corresponds to 1em, <code>medium<: indent odd/code> to 1.5em, and even lines in \obeylines scopes* <code>bignormal</code> to 2em.: what does this do?
== Setting up indentation after an environment ==
Suppose we want to indent all paragraphs by 20pt: we can use<texcode>\{{cmd|setupindenting[20pt}} does not take care of indenting after environments, yes]</texcode>  This is what one typically uses in a documentsuch as ConTeXt's itemizes, enumerations, definitions, formulas and floats. The other keys are needed onlyfor special cases (like typesetting quotations It also does not take care of indenting after heads such as chapters, sections, and verses)subsections.  
<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>% indent paragraphs after formulas if there is a blank space in between\setupheadssetupformulas[indentnext=yesauto]
</texcode>
If we want paragraphs after formulas to be indented only if weleave a blank space after them, we can say== Setting up indentation inside environments ==
There is one case that is not taken care of by {{cmd|setupindenting}} and the <texcodecode>\setupformulas[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=auto]</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}}:
There is one case that is not taken care of by <cmdcontext source="yes" text="gives">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 as the arguments of <cmd>setupindenting</cmd> command. For example, if we set\setuppapersize[A5]
<texcode>\setupitemgroup[itemize]setupindenting[indenting={40ptmedium,yes}]</texcode> then the following : <context source="yes" text="gives" scale="0.8">\setupitemgroup[itemize][indenting={40pt,yesnext}]
\startitemize
\item This is an example of a multi|-|paragraph
</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 ==
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