What are the pros and cons of using active characters instead of macros in text? Would it make sense to implement a “simplified markup” parser in Latex to make code more readable?
Rationale
Latex-style inline markup can get distracting quickly.
Most people, like me, probably only use a limited set of commands.
(We’ll ignore environments for now.)
One can define shorter mnemonic macros like \bold
to alias \textbf
,
but that hardly saves any keystrokes
– not for \
, {
and }
in particular,
which are difficult to access in some keyboard layouts.
At the same time, many (ASCII) punctuation marks are not used much or only in specific spatial scenarios, i.e. some are surrounded by whitespace characters, others have a space on one side and a letter on the other, yet others only follow or precede digits (maybe separated by a space) or are only useful in math mode altogether. French differs as usual.
Many people, like me, are used to markdown (as used e.g. on SX), reStructuredText (rST), textile, ASCIIdoc, Emacs org-mode, Haddock or some variant of wiki markup (e.g. MediaWiki or MoinMoin syntax). They all reuse punctuation characters to mark-up plain text without adding too much visible noise.
Some of these are already active characters in Latex,
e.g. \
, {
, }
, '
, &
and $
, ^
and _
in math mode, with some babel.sty
variants or enquote.sty
options "
and ~
, too.
One could activate many more to do away with verbose macros.
I think that is how wiki.sty
works.
The tipa.sty
magic may work in a similar way.
(I prefer direct Unicode entry, though.)
The thing is,
everyone has slightly different needs so these shortcuts should be configurable.
I’m considering to try to write some code that makes it easy to add such shortcuts to one’s documents,
maybe even up to the point where the source between \begin{document}
and \end{document}
becomes indiscernible from markdown or the like.
Alas, I really don’t know much about active characters and catcodes yet. If everybody thinks what I want to do is a Bad Idea, I will spare myself the hassle. If someone more knowledgeable would do (or actually has done) it instead, all the better.
Background
I’m writing linguistic texts about grapheme–phoneme interrelations,
therefore I frequently need to include phonologic or graphematic notation,
often in runs of normal prose.
I defined macros like \grapheme{}
and \phoneme{}
for that,
because graphemes are by convention enclosed in angular brackets \langle…\rangle
which are cumbersome to include otherwise.
The slashes of phonemic transcription would be easy to input on the other hand,
but I also prefer a sans-serif font for that,
so a command makes sense not only for structural reasons.
There’s also \phone{}
for phonetic notation of phones enclosed in square brackets,
which are also used for properties
(whose identifiers are uppercase or set in small capitals).
Since I’m into grammatology,
I sometimes even need to discriminate categoric letters and characters from actual graphs and glyphs,
but let’s assume I surround them all by vertical bars with the help of \graphe{}
.
Mostly for completeness,
I also define \morph{}
and \morpheme{}
in curly braces
as well as \lexeme[]{}
which just typesets the mandatory argument in italic and the optional one in single quotes.
\newcommand\wrong[1]{*#1}
\newcommand\ambig[1]{\textsuperscript{?}#1}
\newcommand\phone[1]{\mbox{[\textsf{#1}]}}
\newcommand\phoneme[1]{\mbox{/\textsf{#1}/}}
\newcommand\graphe[1]{\mbox{|#1|}} % SIC!
\newcommand\grapheme[1]{\mbox{$\langle$#1$\rangle$}}
\newcommand\morph[2][]{\mbox{\textup{\{}#2\textup{\}}\textsubscript{#1}}}
\newcommand\morpheme[1]{\morph{\textsc{#1}}}
\newcommand\property[2][±]{\mbox{\textup{[}$#1$#2\textup{]}}}
\newcommand\lexeme[2][]{\textit{#2}\ifthenelse{\isempty{#1}}{}{ ‘#1’}}}
For my needs, I would hence try to get these mappings (subject to change):
[x]
→\phone{x}
/x/
→\phoneme{x}
<x>
→\grapheme{x}
|x|
→\graphe{x}
\{x\}
? →\morph{x}
((x))
? →\morpheme{x}
[[x]]
,[y[x]]
,[[x]y]
→\property[y]{x}
>x<
,>x<y>
,<y>x<
→\lexeme[y]{x}
*x*
or*x
→\wrong{x}
?x?
or?x
→\ambig{x}
Some of the following mappings may also make sense for more generic use:
_x_
or~x~
→\emph{x}
__x__
or~~x~~
→\textit{x}
*x*
→\alert{x}
or\strong{x}
**x**
\textbf{x}
\NL*
→\item
with automaticitemize
environment if necessary, also#
forenumerate
and;
or:
fordescription
+x+
→\textsc{x}
/\person{x}
or{\large x}
++x++
→\MakeUppercase{x}
or{\Large x}
=x=
→\chapter{x}
==x==
→section{x}
etc.
§x§
→\autocite{x}
@x@
→\ref{x}
,\cref{x}
^x^
→\footnote{x}
PS: I know I could use pandoc and similar tools to generate make .tex
files,
but they’re usually hard to adapt to ones individual Latex needs, too.
PPS: I also know I might encounter problems with beamer.cls
,
because of its ubiquitous use of <
and >
.
\XeTeXinterchartoks
etc.. I guess one could hack something up using that, too.