The Semantic-Markup Package For Meaningful Markup: Andrew A. Cashner January 29, 2020
The Semantic-Markup Package For Meaningful Markup: Andrew A. Cashner January 29, 2020
Markup
Andrew A. Cashner∗
January 29, 2020
Contents
1 Package Options 1
1.1 defaultquotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 endnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
4 Footnote Environment 4
5 Musical Symbols 4
6 Code 5
1 Package Options
1.1 defaultquotes
The package configures csquotes to place end punctuation inside quotation
marks, according to United States usage. Use the defaultquotes package op-
tion to restore the default behavior of csquotes.
∗ [email protected]
1
1.2 endnotes
The endnotes option converts footnotes to endnotes, including footnotes created
with this package’s Footnote environment. On its own, this option loads the
endnotes package and does everything necessary for endnotes. You can define
the following commands to adjust the behavior:
If you want to setup the endnotes in a completely different way or avoid con-
flicts with another package, you can do \renewcommand{\SetupEndnotes}{} to
eliminate all of this or you can renew the command to do something else.
2
Package Command Alias Use
\quoted \textquote Quoted material, taking care of end
punctuation: instead of “word,” write
\quoted {word},
\soCalled \textquote Scare quotes
\strong \textbf Highlight emphasis just as in HTML
\code \texttt Computer code in teletype font (not ver-
batim)
\term \emph Technical terms, set in italics
\mentioned \emph Referring to a word as a word rather
than to its meaning, as in philological
discussion
\foreign \emph Foreign term
\worktitle \emph Title of a complete work (of literature,
art, music), set in italics; use for books,
journal titles
\parttitle \textquote Title of a portion of a work, set in quo-
tation marks, such as a journal article,
song on an album
3
4 Footnote Environment
When writing many long footnotes it can be useful to have an environment
for footnotes. Here one is defined using the environ package. You still have to
escape the end of the line before the footnote begins. Use like so:
Body text.%
\begin{Footnote}
Footnote text.
More footnote text.
\end{Footnote}
Continuation of body text.
5 Musical Symbols
Shorthands are defined for musical accidentals, using LATEX math-mode sym-
bols. These could be redefined to use Unicode symbols if the font contains them,
or with commands from the lilyglyphs package. Remember that like all com-
mands without arguments, LATEX will ignore the space after the command-name,
so you will need to write \fl{} or \fl\ . There is also a command for octave
numbers, for the system in which middle C begins the fourth octave.
If the musicography package is loaded, it will redefine the commands \fl,
\sh, and \na to use nicer symbols from the MusiXTEX fonts.
Command Alias
\fl $\flat$
\na $\natural$
\sh $\sharp$
\octave \textsubscript
6–5 3
There is a 4–3 cadential pattern before the shift to 4 time. The melody begins
on F]4 .
For more complex notation, such as three-level numerals, or stacked figured-
bass symbols with accidentals or slashes, you will have to devise your own so-
lution.
4
6 Code
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{semantic-markup}[2020/01/29
Macros for TEI-like semantic markup]
% Copyright 2020 Andrew A. Cashner, [email protected]
% CHANGE LOG
% 2020-01-29 - \musfig uses stackengine now instead of amsmath
% 2018-09-07 - ! and ? removed from autopunct for csquotes
% 2018-05-21 - Use fontspec’s definition of ‘\strong‘ if it is loaded
% - Use musicography’s definition of ‘\fl‘, ‘\sh‘, ‘\na‘ commands if
% it is loaded
% - ‘\wtitle‘ and ‘\ptitle‘ shorthands added
% - Customizable commands added for endnotes option
%
% 2016-09-22 - ‘endnotes’ option added
% 2016-09-01 - First version on CTAN
\ProcessOptions\relax
5
%**************************
\RequirePackage{xparse}
\RequirePackage{csquotes}
\ifdefaultquotes\else
% Put end punctuation inside quotation marks
% for the specified marks
\renewcommand{\mktextquote}[6]{#1#2#4#5#3#6}
\DeclareAutoPunct{.,}
\fi
% NB: fontspec defines its own \strong command, so only define this if fontspec
% not loaded
\@ifpackageloaded{fontspec}{}{%
\NewDocumentCommand{\strong}{}
{\textbf}
}
\NewDocumentCommand{\quoted}{}
{\textquote}
\NewDocumentCommand{\soCalled}{}
{\textquote}
\NewDocumentCommand{\code}{}
{\texttt}
\NewDocumentCommand{\term}{}
{\emph}
\NewDocumentCommand{\mentioned}{}
{\emph}
\NewDocumentCommand{\foreign}{}
{\emph}
\NewDocumentCommand{\worktitle}{}
{\emph}
\NewDocumentCommand{\parttitle}{}
{\textquote}
% editorial addition
\NewDocumentCommand{\add}{ m }
{[#1]}
6
% editorial ellipsis
\NewDocumentCommand{\Dots}{}{\add{\dots}}
% explanatory gloss of technical or foreign term
\NewDocumentCommand{\gloss}{ m m }{%
\mentioned{#1} (#2)%
}
% explanatory gloss of word in quotation marks
\NewDocumentCommand{\quotedgloss}{ m m }{%
\quoted{#1} (#2)%
}
%*******************
% Identify problem spot in draft
\NewDocumentCommand{\XXX}{ O{FIX} }{%
\strong{\add{#1}}%
}
% Indicate citation to be filled in later
% Optional argument for indicating the source
\NewDocumentCommand{\citXXX}{ o }{%
\footnote{\strong{\add{Citation needed\IfValueTF{#1}{: #1}{}}}}%
}
%*******************
% Footnote as environment
\RequirePackage{environ}
\NewEnviron{Footnote}{\footnote{\BODY}}[]
%******************
% Endnotes, if desired
\ifendnotes
\RequirePackage{endnotes}
\AtBeginDocument{%
\SetupEndnotes{}%
7
% Footnote environment adjusted to fix expansion problem
\RenewEnviron{Footnote}{\expandafter\footnote\expandafter{\BODY}}[]%
}%
\fi
%******************
%****************************************
% MUSIC SYMBOLS
% Octave subscripts
\NewDocumentCommand{\octave}{ }{\textsubscript}
% Music figures
\RequirePackage{stackengine}
\setstackgap{S}{2pt}
\NewDocumentCommand{\musfig}{ m m }{%
\Shortstack{#1 #2}%
}
% Meter signatures
\NewDocumentCommand{\meter}{}{\musfig}
\endinput