% !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
		(b, c, red); <key>{CamelCase} is one of the 151 CSS
		colours (SteelBlue); <key>{UPPERCASE} is a font name
		(DEJAVU SANS). Nothing else to memorise.
	}
	
	<h1>Inline styles and colours
	<p>{
		The styles are <b>{bold}, <i>{italic}, <u>{underlined}, <emph>{emphasis},
		<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 Npt or 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 p above is
		simply <<tab>>: a one-tab first-line indent, justification already
		being the default. The number on a tab or a skip is always a prefix —
		2tab, 3lines — and singular/plural is enforced: line or
		1line, then 2lines, 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>Escapes and special characters
	<p>{
		A handful of characters drive the language: angle brackets open and close
		a tag, braces delimit a block, the hash interpolates. To print one of them
		literally, double it — that is the whole rule.
	}
	<box line:Purple fill:Lavender radius:3 title:{Doubling makes a literal}>{
		Literal angles: << and >>. Literal braces: {{ and }}. Literal hash: ##.
		A balanced pair prints as one even inside a frame, so set-builder
		notation like {{ x : x > 0 }} and the empty set {{}} are written as
		pairs; a quoted tag such as <<box line:Navy>> shows itself, unparsed.
	}
	<p>{
		So a doubled character always prints as the single character itself. The
		underscore, ampersand, percent and tilde are handled for you — type them
		as they are:
	}
	<box line:Purple fill:Lavender radius:3>{
		Set notation like {{1, 2, 3}}, a ratio a##b, 50% off, x_1 & y_2, a ~ b.
	}
	<p>{
		The backslash is an ordinary character now, so a file path or a Windows
		folder prints exactly as written — nothing to escape:
	}
	<box line:Purple fill:Lavender radius:3 title:{A backslash is just a backslash}>{
		The path C:\Users\Leo\Documents and the regex \d+\s*\w stay verbatim.
	}
	<p>{
		A line break inside a paragraph is the tag <<nextline>> (a blank line
		already starts a new paragraph, so you rarely need it):
	}
	<box line:Purple fill:Lavender radius:3>{
		First line of an address <nextline> second line, same paragraph.
	}
	
	<h1>Structure and the table of contents
	<p>{
		The heading keywords section, subsection and
		subsubsection — folded into h1, h2, h3 at the top —
		number themselves and feed the <<tableofcontents>> printed on the first page
		(a title in braces, <<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.
	}
	
	<h1>Lists
	<p>{
		A list is written <<list:STYLE>> — the style follows the name, one
		item per line, no item tag. Bullets are disc, circle,
		square, none; numbered lists are decimal, alpha,
		ALPHA, roman, ROMAN (the case of the keyword sets the
		case of the letters); 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 let h1 = <<navy b section>>
		to <<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}