Created
April 25, 2026 13:41
-
-
Save hubgit/a8fc8c7a1bafca1b0b2d6db923ec856e to your computer and use it in GitHub Desktop.
Example document for LuaLaTeX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \documentclass{article} | |
| \usepackage{fontspec} % Select OpenType/TrueType system fonts | |
| \usepackage{microtype} % Improve spacing, protrusion, and overall typography | |
| \usepackage[british]{babel} % Language-specific hyphenation and document strings | |
| \usepackage{csquotes} % Context-sensitive quotation marks | |
| \usepackage{mathtools} % Extensions and fixes for amsmath | |
| \usepackage{amssymb} % Additional mathematical symbols | |
| \usepackage{unicode-math} % Use OpenType Unicode math fonts | |
| \usepackage{siunitx} % Consistent numbers, units, and scientific notation | |
| \usepackage{booktabs} % Professional-quality table rules | |
| \usepackage{tabularx} % Tables with automatically stretching columns | |
| \usepackage{array} % Extended table column definitions | |
| \usepackage{graphicx} % Include and scale images | |
| \usepackage{xcolor} % Define and use colours | |
| \usepackage[backend=biber, style=numeric]{biblatex} % Modern bibliography management | |
| \addbibresource{references.bib} | |
| \usepackage{hyperref} % Clickable links, references, and PDF metadata | |
| \usepackage{cleveref} % Smart cross-references with object names | |
| % Font choices for the demonstration. Adjust these to fonts installed on your system. | |
| \setmainfont{Libertinus Serif} | |
| \setsansfont{Libertinus Sans} | |
| \setmonofont{Libertinus Mono} | |
| \setmathfont{Libertinus Math} | |
| % Hyperlink metadata and appearance. | |
| \hypersetup{ | |
| pdftitle={A Modern LaTeX Package Demonstration}, | |
| pdfauthor={Author Name}, | |
| colorlinks=true, | |
| linkcolor=blue, | |
| citecolor=blue, | |
| urlcolor=blue | |
| } | |
| % A custom table column type using array + tabularx. | |
| \newcolumntype{L}{>{\raggedright\arraybackslash}X} | |
| % A custom colour using xcolor. | |
| \definecolor{brandblue}{HTML}{0057B8} | |
| % mathtools paired delimiters. | |
| \DeclarePairedDelimiter{\abs}{\lvert}{\rvert} | |
| \DeclarePairedDelimiter{\norm}{\lVert}{\rVert} | |
| \title{A Modern LaTeX Package Demonstration} | |
| \author{Author Name} | |
| \date{\today} | |
| \begin{document} | |
| \maketitle | |
| \tableofcontents | |
| \section{Overview} | |
| This short document demonstrates a compact set of packages commonly used in modern technical writing. It includes examples of font selection, typography, language-aware text, quotation handling, mathematics, units, tables, graphics, colour, bibliographies, hyperlinks, and cross-references. | |
| The examples are intentionally small. Their purpose is to show what each package contributes without turning the document into a full template. | |
| \section{Fonts with \texttt{fontspec}} | |
| The body text, sans-serif text, monospaced text, and mathematics are all selected explicitly in the preamble. | |
| Here is normal serif text. Here is {\sffamily sans-serif text}. Here is \texttt{monospaced text}. Because fonts are selected by name, the preamble is easier to read and adjust. | |
| \section{Typography with \texttt{microtype}} | |
| This paragraph is included to give the typography engine something to work with. The package can improve paragraph colour, margin appearance, and line breaking through subtle adjustments such as protrusion and expansion. These effects are usually most visible in justified paragraphs with punctuation near the margins. | |
| \section{Language Support with \texttt{babel}} | |
| The document uses British English conventions. Language selection affects hyphenation patterns and automatically generated document strings such as the table of contents heading. | |
| A multilingual document could switch language rules where needed, but this example keeps a single document language. | |
| \section{Quotations with \texttt{csquotes}} | |
| The \texttt{csquotes} package provides semantic quotation commands. For example: | |
| \begin{quote} | |
| \enquote{This quotation is produced with a language-aware quotation command.} | |
| \end{quote} | |
| Nested quotations are also handled more cleanly: \enquote{She said, \enquote{Use semantic quotation commands instead of manual punctuation.}} | |
| \section{Mathematics with \texttt{mathtools}, \texttt{amssymb}, and \texttt{unicode-math}}\label{sec:math} | |
| The \texttt{mathtools} package provides a strong foundation for displayed equations and mathematical notation. The paired delimiter commands declared in the preamble allow notation such as \(\abs{x}\) and \(\norm{v}\). | |
| \begin{equation}\label{eq:cauchy} | |
| \abs*{\sum_{i=1}^{n} x_i y_i} | |
| \leq | |
| \norm*{x}_2 \norm*{y}_2 | |
| \end{equation} | |
| The \texttt{amssymb} package supplies familiar mathematical symbols such as \(\mathbb{R}\), \(\varnothing\), \(\nexists\), and \(\leqslant\). | |
| The \texttt{unicode-math} package allows the mathematical font to be selected directly, so text and mathematics can be chosen as a coherent pair. | |
| \section{Numbers and Units with \texttt{siunitx}}\label{sec:units} | |
| The \texttt{siunitx} package keeps numbers and units consistent: | |
| \begin{itemize} | |
| \item Speed: \qty{10}{\metre\per\second} | |
| \item Mass: \qty{3.5}{\kilogram} | |
| \item Energy: \qty{1.23e-4}{\joule} | |
| \item Angle: \ang{37.5} | |
| \end{itemize} | |
| It is especially useful in numerical tables, where values can be aligned by decimal marker. | |
| \section{Tables with \texttt{booktabs}, \texttt{tabularx}, and \texttt{array}}\label{sec:tables} | |
| \Cref{tab:packages} uses \texttt{booktabs} for the horizontal rules, \texttt{tabularx} for flexible column widths, and \texttt{array} for the custom \texttt{L} column type. | |
| \begin{table}[htbp] | |
| \centering | |
| \caption{Examples of package roles in a document} | |
| \label{tab:packages} | |
| \begin{tabularx}{\linewidth}{lL} | |
| \toprule | |
| Package & Role \\ | |
| \midrule | |
| \texttt{booktabs} & Provides clean horizontal rules for professional-looking tables. \\ | |
| \texttt{tabularx} & Allows a table to fit a chosen width while wrapping explanatory text. \\ | |
| \texttt{array} & Supports custom column definitions and reusable table formatting. \\ | |
| \bottomrule | |
| \end{tabularx} | |
| \end{table} | |
| \section{Graphics with \texttt{graphicx}}\label{sec:graphics} | |
| The \texttt{graphicx} package includes and scales external graphics. \Cref{fig:example} uses a simple rule box as a placeholder, so the document remains self-contained. | |
| \begin{figure}[htbp] | |
| \centering | |
| \fbox{\rule{0pt}{35mm}\rule{70mm}{0pt}} | |
| \caption{A placeholder for an included graphic. Replace this box with \texttt{\textbackslash includegraphics}.} | |
| \label{fig:example} | |
| \end{figure} | |
| A real figure might use a command such as \texttt{\textbackslash includegraphics[width=.8\textbackslash linewidth]\{figure.pdf\}}. | |
| \section{Colour with \texttt{xcolor}} | |
| The \texttt{xcolor} package defines and applies colours. This sentence contains \textcolor{brandblue}{brand-coloured text} using a colour defined in the preamble. | |
| Colour is also commonly used for hyperlinks, annotations, diagrams, and table emphasis. | |
| \section{Bibliographies with \texttt{biblatex}}\label{sec:bibliography} | |
| The \texttt{biblatex} package provides modern citation and bibliography management. A citation might look like this: \cite{knuth1984}. | |
| This demonstration expects a separate file named \texttt{references.bib}. For example, that file could contain: | |
| \begin{verbatim} | |
| @book{knuth1984, | |
| author = {Donald E. Knuth}, | |
| title = {The TeXbook}, | |
| year = {1984}, | |
| publisher = {Addison-Wesley} | |
| } | |
| \end{verbatim} | |
| \section{Links with \texttt{hyperref}} | |
| The \texttt{hyperref} package makes cross-references, URLs, citations, and table-of-contents entries clickable in the PDF. | |
| Here is an external link: \url{https://www.latex-project.org/}. | |
| Internal links are created automatically by references such as \cref{sec:math}, \cref{sec:units}, and \cref{sec:tables}. | |
| \section{Smart References with \texttt{cleveref}} | |
| The \texttt{cleveref} package adds the object name automatically. Instead of manually writing \enquote{figure}, \enquote{table}, or \enquote{equation}, the document can use one command: | |
| \begin{itemize} | |
| \item \cref{eq:cauchy} | |
| \item \cref{tab:packages} | |
| \item \cref{fig:example} | |
| \end{itemize} | |
| It can also group references, as in \cref{sec:math,sec:units,sec:tables}. | |
| \section{Conclusion} | |
| Together, these packages provide a practical foundation for technical writing: explicit fonts, improved typography, language-aware prose, robust mathematics, consistent units, better tables, image support, colour, citations, hyperlinks, and reliable cross-references. | |
| \printbibliography | |
| \end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment