Skip to content

Instantly share code, notes, and snippets.

@dexeonify
Created January 2, 2026 09:14
Show Gist options
  • Select an option

  • Save dexeonify/173fbd120d585ac99872e4f2679e8333 to your computer and use it in GitHub Desktop.

Select an option

Save dexeonify/173fbd120d585ac99872e4f2679e8333 to your computer and use it in GitHub Desktop.
A heavily modified LaTex template file for Xournal++, bypassing the forced math mode and unlocking full LaTex embedding potential. See https://github.com/xournalpp/xournalpp/blob/master/resources/default_template.tex for comparison.
% This template uses the scontents package, which is only available on relatively recent TeX distributions.
% In case it is not available on your system, use the legacy_template.tex
\documentclass[varwidth=500pt, border=2pt]{standalone}
%% Global Packages ------------------------------------------------------------
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{textgreek}
\usepackage{siunitx}
% Math packages
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pgfplots}
% Chemistry packages
\usepackage[version=4]{mhchem}
\usepackage{chemfig}
\usepackage[minimal]{chemmacros}
\usetikzlibrary{calc}
%% Chemistry Macros -----------------------------------------------------------
% Orbital box notation
\newcommand{\orbox}[2]{
\newcommand*{\up}{%
\fbox{\( \mathord\upharpoonleft\phantom{\downharpoonright} \)}%
}%
\newcommand*{\down}{%
\fbox{\( \mathord\downharpoonleft\phantom{\upharpoonright} \)}%
}%
\newcommand*{\updown}{%
\fbox{\( \upharpoonleft\downharpoonright \)}%
}%
\newcommand*{\blank}{%
\fbox{\( \phantom{\downharpoonright}\phantom{\downharpoonright} \)}%
}%
\setlength\tabcolsep{0pt}% remove extra horizontal space from tabular
\begin{tabular}{c}%
#2 \\
[2pt]#1%
\end{tabular}
}
% Default settings for drawing Lewis structure
\setcharge{
extra sep=0.3em,
.radius=0.2ex,
.style={fill=blue,draw=none}
}
%% Mathematics Macros ---------------------------------------------------------
% Enter aligned equation environment quickly
\newcommand{\aln}[1]{%
\[%
\begin{aligned}%
#1%
\end{aligned}%
\]%
}
% Auto-size bracket
\newcommand*{\brc}[1]{%
\left(#1\right)%
}
% Long division
\newcommand*{\longdiv}[1]{%
\strut#1%
\kern.25em%
\smash{ \hbox{\big)} }%
\mkern-8mu%
}
% Plot function graphs
\pgfplotsset{compat=newest} % Allows to place the legend below plot
\NewDocumentCommand{\graph}{O{} O{} m}{
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$,
ylabel=$y$,
axis lines=center,
samples=100,
\IfBlankF{#1}{#1}
]
\addplot[]{#3};
\end{axis}
\end{tikzpicture}
}
% Nicely formatted definite integrals
\NewDocumentCommand{\intf}{o o m O{x}}{
\int%
\IfValueT{#1}{_{#1}}
\IfValueT{#2}{^{#2}}
#3 \mathop{}\!
\mathrm{d}#4
}
\newcommand*{\intb}[3]{
\left[ #3 \right]_{#1}^{#2}
}
% Combination and permutation
\newcommand*{\nPr}[2]{
{}^{#1}\!P_{#2}
}
\newcommand*{\nCr}[2]{
{}^{#1}C_{#2}
}
%% Xournal++ default_template.tex ---------------------------------------------
% for storing in memory verbatim content to be reused later
\usepackage{scontents}
% Color support
\usepackage{xcolor}
\definecolor{xpp_font_color}{HTML}{%%XPP_TEXT_COLOR%%}
% User input
\begin{scontents}[store-env=preview]
%%XPP_TOOL_INPUT%%
\end{scontents}
\begin{document}
% Render the user input
\textcolor{xpp_font_color}{\getstored[1]{preview}}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment