Skip to content

Commit

Permalink
Use TEXINPUTS for locating my .tex/.sty files
Browse files Browse the repository at this point in the history
  • Loading branch information
utensil committed Aug 18, 2024
1 parent 05e09b6 commit 408cee4
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ so I can check Jon Sterling's use of Forester conveniently.
In order to use `dvisvgm` required by forester to compile LaTeX to SVG, I have to:

```bash
brew uninstall textlive
brew uninstall texlive
brew install --cask mactex
```

Expand Down
2 changes: 1 addition & 1 deletion assets/article.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<xsl:include href="latex.xsl" />

<xsl:template match="/">
<xsl:text>\input{../tex/an_article}</xsl:text>
<xsl:text>\input{an_article}</xsl:text>

<xsl:apply-templates select="/f:tree/f:frontmatter" mode="top" />

Expand Down
2 changes: 1 addition & 1 deletion assets/book.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<xsl:include href="latex.xsl" />

<xsl:template match="/">
<xsl:text>\input{../tex/a_book}</xsl:text>
<xsl:text>\input{a_book}</xsl:text>

<xsl:apply-templates select="/f:tree/f:frontmatter" mode="top" />

Expand Down
7 changes: 7 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/bash

SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
PROJECT_ROOT="$SCRIPT_DIR"

export TEXINPUTS=.:$PROJECT_ROOT/tex/:

echo "TEXINPUTS=$TEXINPUTS"

function show_result {
# if return code is zero, then echo "Done" else echo "Failed"
if [ $? -ne 0 ]; then
Expand Down
2 changes: 1 addition & 1 deletion dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

echo "🛁 Cleaning up build and output"
# rm -rf build
rm -rf output
# rm -rf output
./build.sh

watchexec --quiet --no-vcs-ignore --project-origin . --on-busy-update queue --poll 500ms -e tree,tex,css,js,xsl,glsl -w trees -w assets -w tex --emit-events-to=stdio -- ./build_changed.sh &
Expand Down
2 changes: 1 addition & 1 deletion tex/a_book.tex
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
\documentclass[a4paper]{book}
\usepackage{fontspec} % requires xelatex
\input{../tex/preamble}
\input{preamble}
2 changes: 1 addition & 1 deletion tex/a_minipage.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\input{../tex/preamble}
\input{preamble}
\usepackage[a4paper,lmargin=1in,rmargin=1in,tmargin=0.82in,bmargin=1ex]{geometry}

% shims for macros useful only in LaTeX but not on forester web pages
Expand Down
2 changes: 1 addition & 1 deletion tex/an_article.tex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
% \the\realoutput
% }
\usepackage{fontspec} % requires xelatex
\input{../tex/preamble}
\input{preamble}
% \newcommand{\frontmatter}{}
% \newcommand{\mainmatter}{}
% \newcommand{\backmatter}{}
Expand Down
2 changes: 1 addition & 1 deletion tex/code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
\definecolor{sortcolor}{rgb}{0.1, 0.5, 0.1} % green
\definecolor{attributecolor}{rgb}{0.7, 0.1, 0.1} % red

\def\lstlanguagefiles{../tex/lstlean.tex}
\def\lstlanguagefiles{lstlean.tex}
% set default language
\lstset{language=lean}
2 changes: 1 addition & 1 deletion tex/diagrams.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
\usepgfplotslibrary{colormaps}
\usepackage[outline]{contour} % glow around text
% https://q.uiver.app/
\usepackage{../tex/quiver}
\usepackage{quiver}
\usetikzlibrary{math}
\usetikzlibrary{matrix,arrows}
\usetikzlibrary{backgrounds,intersections,fit,positioning,calc,shapes,spath3}
Expand Down
10 changes: 5 additions & 5 deletions tex/preamble.tex
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@

%% Framed boxes for definitions, theorems, remarks etc.

\input{../tex/mdframed}
% \input{../tex/tcolorbox}
\input{mdframed}
% \input{tcolorbox}

% for tree ids in the margin
% \usepackage{marginnote}
Expand Down Expand Up @@ -132,9 +132,9 @@
% we have errors like:
% (/usr/local/texlive/2024/texmf-dist/tex/latex/spath3/tikzlibraryspath3.code.tex
% (/usr/local/texlive/2024/texmf-dist/tex/latex/spath3/spath3.sty)))
% (../tex/string-diagrams.tex
% (string-diagrams.tex
% (/usr/local/texlive/2024/texmf-dist/tex/latex/string-diagrams/string-diagrams.s
% ty)) (../tex/diagrams.tex
% ty)) (diagrams.tex

% ! LaTeX Error: Command \dontworryaboutit already defined.
% Or name \end... illegal, see p.192 of the manual.
Expand Down Expand Up @@ -180,4 +180,4 @@

%% Code highlighting

\input{../tex/code}
\input{code}
2 changes: 1 addition & 1 deletion tex/string-diagrams.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% \usepackage{string-diagrams}
\usepackage{../tex/string-diag}
\usepackage{string-diag}
% \usepackage{xparse}

\definecolor{catccolor}{RGB}{255,244,138}
Expand Down
10 changes: 5 additions & 5 deletions trees/latex-preamble.tree
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@

\p{These LaTeX preambles are used by [[macros]].}

\p{We place LaTeX preambles in the directory \code{tex} which is at the same level of the directory \code{trees}, but we need to refer to them \code{../tex/name.tex}, because LaTeX is running in \code{build} directory.}
\p{We place LaTeX preambles in the directory \code{tex}, and add the absolute directory path to \code{TEXINPUTS} as we can't assume where LaTeX is building from.}

\p{Here we define:}

\p{\code{latex-preamble/common}: Common LaTeX preambles in \code{preamble.tex}.}

\def\latex-preamble/common\verb<<<|
\input{../tex/preamble}
\input{preamble}
<<<

\p{\code{latex-preamble/minipage}: LaTeX preambles for embeding LaTeX in minipage.}

\def\latex-preamble/minipage\verb<<<|
\input{../tex/a_minipage}
\input{a_minipage}
<<<

\def\latex-preamble/diagrams\verb<<<|
\input{../tex/diagrams}
\input{diagrams}
<<<

\def\latex-preamble/string-diagrams\verb<<<|
\input{../tex/string-diagrams}
\input{string-diagrams}
<<<

0 comments on commit 408cee4

Please sign in to comment.