Skip to content

Commit

Permalink
Add \mark, improve doc
Browse files Browse the repository at this point in the history
  • Loading branch information
utensil committed Apr 30, 2024
1 parent 67bba9c commit 259efea
Showing 1 changed file with 64 additions and 55 deletions.
119 changes: 64 additions & 55 deletions trees/macros.tree
Original file line number Diff line number Diff line change
@@ -1,9 +1,66 @@
\title{basic macros}

\p{Here we define:}

\import{latex-preamble}

\xmlns:html{http://www.w3.org/1999/xhtml}

\strong{Useful macros from [jonsterling's macros](https://git.sr.ht/~jonsterling/public-trees/tree/main/item/base-macros.tree)}

\p{\code{citek[uid]}: Refer to a reference entry with brackets.}

\def\citek[uid]{
\let\escape[x]{\x}

[\escape{[\uid]}](\uid)
}

\p{\code{mark[body]}: Some yellow background mark text.}

\def\mark[body]{\<html:mark>{\body}}

\strong{Useful macros from [CAIMEOX's macros](https://github.com/CAIMEOX/caimeox.github.io/blob/main/trees/macros.tree)}

\p{\code{block[tit][body]}: A block that is part of the TOC.}

\def\block[tit][body]{
\subtree{
\title{\tit}
\body
}
}

\p{\code{section[tit][body]}: A section that is NOT part of the TOC.}

\def\section[tit][body]{
\scope{
\put\transclude/toc{false}
\subtree{
\tit
\body
}
}
}

\p{\code{tikz[g]}: A TikZ graph rendered via LaTeX.}

\def\tikz[g]{
\xml{center}{\tex{
\usepackage{tikz-cd}
\usepackage{amssymb}
}{
\g
}
}
}

\p{\code{codeblock[lang][body]}: A code block specifying the language.}

\def\codeblock[lang][body]{
\pre{ \xml{code}[class]{\lang}{\body} }
}

\strong{Useful macros we defined}

\alloc\base/tex-preamble

\p{\code{minitex[body]}: Typesetting LaTeX code in a minipage, with the width of an A5 paper,
Expand All @@ -30,40 +87,31 @@ so the text size almost matches the size output by native forester code. This do
}
}

% From: https://git.sr.ht/~jonsterling/public-trees/tree/main/item/base-macros.tree
\p{\code{citek[uid]}: Refer to a reference entry with brackets.}

\def\citek[uid]{
\let\escape[x]{\x}

[\escape{[\uid]}](\uid)
}

\p{\code{texdef[name][reference][body]}: Making a \code{minitex} definition with a reference.}
\p{\code{texdef[name][reference][body]}: A \code{minitex} definition with a reference.}

\def\texdef[name][reference][body]{
\title{\name \citek{\reference}}
\taxon{definition}
\minitex{\body}
}

\p{\code{wikiref[name][pageid]}: Making a reference to a Wikipedia article.}
\p{\code{wikiref[name][pageid]}: A reference to a Wikipedia article.}

\def\wikiref[name][pageid]{
\title{\name - Wikipedia}
\meta{external}{https://en.wikipedia.org/wiki/\pageid}
\taxon{reference}
}

\p{\code{nlabref[name][wikiid]}: Making a reference to a nLab article.}
\p{\code{nlabref[name][pageid]}: A reference to a nLab article.}

\def\nlabref[name][pageid]{
\title{\name - nLab}
\meta{external}{https://ncatlab.org/nlab/show/\pageid}
\taxon{reference}
}

\p{\code{edit[treeid]}: Making a reference to a nLab article.}
\p{\code{edit[treeid]}: A link to the source code of a tree.}

\def\edit[treeid]{
\let\escape[x]{\x}
Expand All @@ -87,43 +135,4 @@ so the text size almost matches the size output by native forester code. This do
}
}

\p{Below are some useful macros taken from [CAIMEOX's macros](https://github.com/CAIMEOX/caimeox.github.io/blob/main/trees/macros.tree):}

\p{\code{block[tit][body]}: A block that is part of the TOC.}

\def\block[tit][body]{
\subtree{
\title{\tit}
\body
}
}

\p{\code{section[tit][body]}: A section that is NOT part of the TOC.}

\def\section[tit][body]{
\scope{
\put\transclude/toc{false}
\subtree{
\tit
\body
}
}
}

\p{\code{tikz[g]}: A TikZ graph rendered via LaTeX.}

\def\tikz[g]{
\xml{center}{\tex{
\usepackage{tikz-cd}
\usepackage{amssymb}
}{
\g
}
}
}

\p{\code{codeblock[lang][body]}: A code block specifying the language.}

\def\codeblock[lang][body]{
\pre{ \xml{code}[class]{\lang}{\body} }
}
\meta{source}{ \edit{macros} }

0 comments on commit 259efea

Please sign in to comment.