% !TeX program = lualatex
% =====================================================================
%  01-text-style.tex
%  Text, styling and structure: the case rule, colours, fonts, sizes,
%  alignment, tabs, vertical skips, scripts — then the two ideas that
%  make scholatex scale: factoring repeated styling into aliases, and a real
%  table of contents driven by the heading keywords.
% =====================================================================
\documentclass[
  margins=20,
  font=Latin Modern Roman,
  size=12,
  lang=en
]{scholatex}
\begin{document}

% ---------------------------------------------------------------------
% Factor every recurring style into an alias, once, at the top. From here
% on the document never repeats a tag's attributes: it just names them.
% A heading alias carries its section keyword among the words, so the same
% name works as a heading (<h1>Title) and feeds the table of contents.
% ---------------------------------------------------------------------
let title = <red b 20pt c>
let h1    = <navy b section>
let h2    = <blue i subsection>
let h3    = <teal i subsubsection>
let p     = <tab>
let key   = <b Crimson>

<title>Simple LaTeX — text & structure

<line>

<tableofcontents>{Table of contents}

<h1>The case rule
<p>{
	A tag is written \<...\> and its attributes obey one rule, read off the
	letter case alone: <key>{lowercase} is a short keyword or base colour
	(<tt>{b}, <tt>{c}, <tt>{red}); <key>{CamelCase} is one of the 147 CSS
	colours (<tt>{SteelBlue}); <key>{UPPERCASE} is a font name
	(<tt>{DEJAVU SANS}). Nothing else to memorise.
}

<h1>Inline styles and colours
<p>{
	The styles are <b>{bold}, <i>{italic}, <u>{underlined}, <emph>{emphasis},
	<tt>{typewriter}, <sf>{sans serif} and <sc>{Small Caps}. They combine in
	one tag: <b i red>{bold italic red}.
}
<p>{
	Colours come as short keywords — <red>{red}, <blue>{blue}, <green>{green},
	<navy>{navy}, <orange>{orange}, <purple>{purple}, <teal>{teal} — or as any
	CSS colour in CamelCase: <Tomato>{Tomato}, <SteelBlue>{SteelBlue},
	<ForestGreen>{ForestGreen}, <Crimson>{Crimson}, <DodgerBlue>{DodgerBlue}.
}

<h1>Fonts and sizes
<p>{
	A font name is written in capitals: <DEJAVU SANS 13pt>{this is DejaVu Sans}.
	Sizes are <tt>{Npt} or <tt>{Npx}: <10pt>{small}, <14pt>{medium},
	<20pt>{large}.
}

<h1>Alignment, tabs and skips
<l>Left against the margin (l).
<c>Centred (c).
<r>Right against the margin (r).
<p>{
	A plain paragraph is justified by default, so the alias <tt>{p} above is
	simply <tt>{\<tab\>}: a one-tab first-line indent, justification already
	being the default. The number on a tab or a skip is always a prefix —
	<tt>{2tab}, <tt>{3lines} — and singular/plural is enforced: <tt>{line} or
	<tt>{1line}, then <tt>{2lines}, <tt>{3lines}…
}
Copy the sentence on the lines below:
<i>The little cat drinks its milk.
<3lines>Three lines were skipped above — room to write by hand.

<h1>Scripts
<p>{
	Raised and lowered text ride on the base line without changing its size:
	the 1<up2>{st} of the class; water is H<down2>{2}O; the area is
	x<up2>{2}.
}

<h1>Structure and the table of contents
<p>{
	The heading keywords <tt>{section}, <tt>{subsection} and
	<tt>{subsubsection} — folded into <tt>{h1}, <tt>{h2}, <tt>{h3} at the top —
	number themselves and feed the <tt>{\<tableofcontents\>} printed on the first page
	(a title in braces, <tt>{\<tableofcontents\>{...}}, heads it). You never type a
	number by hand.
}
<h2>A second-level heading
<p>{
	This subsection is numbered one level down and appears indented in the
	table of contents above.
}
<h3>A third-level heading
<p>{
	One level deeper still, with its own counter that restarts whenever its
	parent advances.
}
<h2>Another second-level heading
<p>{
	Opening a new subsection bumps the middle counter and resets the deeper
	one — all automatic.
}

<nextpage h1>Lists
<p>{
	A list is written <tt>{\<list:STYLE\>} — the style follows the name, one
	item per line, no item tag. Bullets are <tt>{disc}, <tt>{circle},
	<tt>{square}, <tt>{none}; numbered lists are <tt>{decimal}, <tt>{alpha},
	<tt>{ALPHA}, <tt>{roman}, <tt>{ROMAN} (the case of the keyword sets the
	case of the letters); <tt>{check} gives checkboxes.
}
<list:decimal>{
	Read the instructions
	Underline the key words
	Write your answer
}
<p>{
	A list written under an item becomes its sub-list, nested as deep as you
	like, each level with its own style:
}
<list:disc>{
	Fruit
	<list:circle>{
		apples
		pears
	}
	Vegetables
	<list:square>{
		carrots
		turnips
	}
}
<p>{
	A checklist is handy for materials or steps to tick off:
}
<list:check>{
	Bring a ruler
	Glue the sheet into the notebook
	Write your name and the date
}

<h1>The payoff of factoring
<p>{
	Every heading and paragraph in this document named an alias rather than
	repeating a list of attributes. Change <tt>{let h1 = \<navy b section\>}
	to <tt>{\<ForestGreen b section\>} once, and every first-level heading
	follows. That single point of control is what keeps a long worksheet
	consistent — and quick to restyle.
}

<r gray i>Gérard — Lyon

\end{document}
