Check out LiX templates on Overleaf. Replace lix.sty
in your overleaf project with the latest one from here to apply updates. The same goes for document classes.
Lix is a meta-package which bundles other LaTeX packages and commands. To use these bundles, simply specify them when importing the LiX package, either in your own document-class, or directly in your main document when using a predefined class. The goal of this package is to speed up writing your documents, but also to simplify the process of defining your own class. Separation of layout and content is made much easier.
LiX aims to be for LaTeX, what LaTeX is for TeX.
Disclaimer: This project breaks conventions and practices, which are considered to be "standard" by the LaTeX community. If you want to learn "pure" LaTeX, this is not the project for you. However, for those of you that want to get stuff done as painlessly as possible: Please enjoy.
Shortcuts: Examples | Syntax | Installation | Scripts | Plans
Motivation:
While LaTeX is the indisputable king for typesetting publishable documents, it does have a steep learning curve and is very syntax-heavy. To ease the burden of typesetting and bring the author's focus back on their content, the syntax should be as light as possible. Defining your own look-and-feel is even more inaccessible, if one is not familiar with basic programming - hence this humble project, which attempts to address these issues.
Code Example
Say, we want to setup a book with the US letter size and a very specific margin, It should have both front and back cover art with a title, a subtitle, multiple authors, etc, which should be added to the pdf-metadata. We would also like a page containing formal information, such as licensing and an ISBN-code and maybe a barcode. We want to be able to include centered, scaled figures and syntax-highlighted code blocks, both captioned. We would also like the document to be in Danish, following specific hyphenation rules, etc.All that can be achieved by this:
\documentclass{thesis} % Or any of the other document classes.
% Document configuration.
\lang {english}
\size {a4}
\cover {path/to/front.pdf}{path/to/back.pdf}
\margins {22mm}{20mm}{21mm}{40mm}
\title {A Cool Title}
\subtitle {And a Cool Subtitle}
\authors {Nicklas Vraa}{Another Guy}{And Another}
\date {01/01/2023}
\isbn {123456789}
\license {CC}{nc}{3.0}{My Company}
\edition {3}{2023}
\watermark {DRAFT}{black!10}
\shield {copyrighted}
% ...
\begin{document}
% ... No need for \maketitle or anything else.
\toc % Include table-of-contents
\h{Introduction} % Level-1 heading.
% ...
\hh{Motivation} % Level-2 heading.
% ...
% Simple code-snippet inclusion.
\code{my_snippet}{python}{
import numpy as np
% ...
}{This code does this and that...}
% ...
% One-line figure import that supports jpg, png, svg, pdf, etc.
\fig{ny_figure}{0.8}{path/to/image.png}{This figures explains how...}
% ...
\end{document}
Imagine the LaTeX code, you would have to write to achieve the same - even when using appropriate packages. The layout of each element should be customized by defining a custom class that builds on top of one of the standard classes. Examples are shown later.
Advantages and Disadvantages
Advantages:
- The source code of a document becomes as easy to read and understand as Markdown and is drastically shorter.
- The style of a document is completely separated from its content, and keeping a consistent style is simpler.
- Configuring your document is simpler, because you don't interface directly with individual packages, which may employ different syntax.
- Creating your own class, which implements a custom look-and-feel, is much easier.
Disadvantages:
- If one wants to change their document into a class that has not been defined using this package, there may be difficulties when compiling. To address this, I've recreated the
IEEEtran
class, as a reference for how to reimplement an existing look using LiX. - You do not have the extreme fine-grained control over your custom class, as you would with pure LaTeX.
- The command names are not as descriptive as standard LaTeX. Minimal impact on source-code readability was prioritized.
Using this package, I've defined some custom classes, which are ready for use, as well as classes which mimic popular formats. Look at the source code for each class to see how easily they were defined. It's very simple to convert to another class, as they all share the exact same syntax. Download the pdf's to see the actual quality.
Paper (tex|pdf) packs as much information as possible, while adhering to the standards of academic research papers. | |||||
Novel (tex|pdf) is meant for fiction with the intent to print. This class supplies cover-, title- and metadata pages, etc. | |||||
Textbook (tex|pdf) is intended for typesetting a large amount of academic content to be printed in book form. | |||||
Novella (tex|pdf) is meant for short-stories with the intent to print. | |||||
News (tex|pdf) is designed as a classic newspaper akin to the The New York Times. | |||||
IEEE (tex|pdf) implements the IEEE journal and transactions template, but using LiX. | |||||
Contract (tex|pdf) is a simple template for a formal contract between an arbitrary number of parties. | |||||
Poem (tex|pdf) is a poem template that features a softer font and can optionally be decorated. |
Also check out:
- Thesis (tex|pdf), which is a mix between the paper and textbook classes, meant for longer academic works.
It is also possible to use the standard classes, like article, report and book, but still benefits from simplified syntax. Simply import the package and specify the stdclass
option, along with any bundles, e.g.:
\documentclass{article}
\usepackage[stdclass, ...]{lix}
This is an overview of the commands, which are available when specifying a certain bundle (in alphabetical order). To those unfamiliar with LaTeX, a command is always prefixed with a backslash \
, mandatory input is enclosed in {}
and optional input is enclosed in []
. Whitespace between a command and its input does not matter. Comments are always prefixed with a percentage symbol %
. In-class commands are not supposed to be used in the main .tex
document, but rather in your .cls
file.
Algorithms
Insert algorithms into your document. Simply type your algorithm in plain text and mix in math typesetting whenever you require, between $
-signs. No need for any escaped \keywords
.
...
\algo{label}{
% Your algorithm.
% $some+math$
}{caption}
...
Algorithms will be subtly highlighted. A label is mandatory, but caption is optional. Indent the block four spaces, as these will be gobbled (removed) in the resulting pdf. This is for better readability in the source file. I recommend indenting all algorithms, tables, figures, etc., to better distinguish them from regular text.
Basics
A collection of essential commands and aliases.
\abstract{summary of findings}
Alias: \blurb{...} (for books).\add{path/to/file.tex/pdf}
Inserts the tex-code from the given file, exactly like\input{}
, but also handles pdf files, which are inserted as pages. If starred, i.e.add*{}
, the given pdf will become the background of the current page.anchor{position}{...}
Aligns its content eitherleft
,right
orcenter
.\authors{first}{second}{...}{sixth}
Handles six entries. Alias: \author{...}.\by{name}{email}{path/to/image.png}
Byline, image is optional.\date{01/01/2023}
The command \today is available.\idnum{123456789}
Could be any alphanumeric.\keywords{this, that, ...}
Alias: \subjects {this, that, ...}.\lang{language}{cus-tom, hyphena-tion, rules}
Localizes text and sets hyphenation rules. Custom list is optional.\subtitle{Some Buzzwords}
Alias: \slogan{...}.\title{A Catchy Title}
Alias: \publication {...}.\toc
Generate table of contents.\url{text}{link}
E.g. {label}{actual url}\cols{n}{...}
Horizontally align content.
Use\begin{columns}{n} ... \end{columns}
if\cols
doesn't work. \\watermark{Text}{color!opacity}
Add text-based watermark, e.g.DRAFT
, orCONFIDENTIAL
with an optionally specified color and opacity, e.g.blue!100
. Defaults togray!50
, if not specified.\shield{Text}{opacity}
Overlays every page with an invisible wall of text to prevent easy extraction of text, i.e. copy-pasting. Opacity is optional and between 0 (invisible) and 1 (black). E.g.\shield{COPYRIGHTED, NICE TRY}
.\np
and\bl
The first is an alias for\newpage
and the second forces a blank line.
In-class commands:
\authorfont{\...}
Apply styling commands to the author text.\use{pkg1, pkg2, ..., pkgN}
Import packages. Simpler alias of \usepackage.\wrap{prepend...}{append...}
Insert code immediately after \begin{document} and (optionally) immediately before \end{document}.
Code
Insert internal code blocks into your document.
...
\code{label}{language}{
% Your code.
}{caption}
...
Or import external code from a file using the starred version.
\code*{label}{language}{path/to/file}{caption}
Code-blocks will be subtly highlighted according to the given language. A label is mandatory, but caption is optional. For no highlighting, set the language to text
. For internal code block, indent the block four spaces, as these will be gobbled (removed) in the resulting pdf. This is for better readability in the source file. I recommend indenting all code-blocks, tables, figures, etc., to better distinguish them from regular text.
Cover
Add a cover to your document, as in the front and back of a book.
\cover{path/to/front.pdf}{path/to/back.pdf}
The images have to be pdf-files. The starred version will not print the title, author, etc. on top of the cover. This is useful, if the cover already includes these. Should be called before\begin{document}
.
In-class commands:
\addFrontCover
\addBackCover
Figures
Place figures, i.e. images and illustrations in your document.
\fig{label}{scale}{path}{caption}
Places your figure at the spot where it's called, if possible. The command is file-format agnostic i.e. it works the same for both regular images and vector graphics. Scale is from 1% to 100% of the current column-width, i.e. from 0.01 to 1. Caption is optional.
Formatting
These command names were chosen to ensure that the readability of the source code is minimally affected.
\b{...}
(b)old text.\c{...}
(c)ode/mono inline.\i{...}
(i)talic text.\l{...}
(l)arge letter.\m{...}
(m)ath inline.\s{...}
(s)trikeout.\u{...}
(u)nderline.
Header
Add a strip of text to the top of each page.
\header{left}{center}{right}
Heading
Add headings to the document.
\h{...}
Level one heading.\hh{...}
Level two heading.\hhh{...}
Level three heading.\hhhh{...}
Level four heading.
Top-level headings will act like chapters in book-like classes, but as sections in article-like classes. Headings will be numbered, unless a *
is added to the command, e.g. \h*{...}
. The regular commands, like \chapter
and \section
can still be used along with their starred counterparts.
\start{odd/even}
Applicable to book-like classes only. It will instruct the compiler to add blank pages such that chapters always start on odd or even pages. In western bookbinding, it is traditional to have chapters start on odd (recto) pages. If this command is not used, no blank pages will be added.
In-class commands:
addheadingseparator{type}
will separate numbering from the actual heading with either aline
or a finaldot
after the number.
ISBN
Add an ISBN-code along with a corresponding barcode to your document. Should be called before \begin{document}
.
\isbn{978-0201529838}
License
Add a license to your document with an automatically generated copyright statement based on the input to the command. Should be called before \begin{document}
.
\license{type}{modifiers}{version}{holder}
An overview of the possible inputs the command. E.g \license{CC}{by-nc-sa}{3.0}.
The Copyright holder is optional.Types Modifiers Versions Creative Commons: CC
Attribution: by
ShareAlike:sa
NoDerivatives:nd
NonCommercial:nc
Universal: 1.0
Unported:3.0
International:4.0
Lists
Add lists to your document. It is possible to nest lists.
\items{
\item Something
\item Another thing.
\items*{
\item Something else
\item The final thing.
}
}
items{...}
will be numbered, and items*{...}
will be bullet points.
Math
Add math-blocks to your document.
\math{label}{
% Regular latex math.
}
The label is required and the math block will be numbered. These are shortcut commands in the math environment:
-
diff{f}{x}
$\frac{d f}{d x}$ (derivative) -
diff*{f}{x}
$\frac{\partial f}{\partial x}$ (partial derivative) -
\mean{x}
$\rightarrow \overline{x}$ -
\Re
$\rightarrow \mathbb{R}$ (Real set) -
\Im
$\rightarrow \mathbb{I}$ (Imaginary set) -
\N
$\rightarrow \mathbb{N}$ (Natural set) -
\Z
$\rightarrow \mathbb{Z}$ (Integer set) -
\Q
$\rightarrow \mathbb{Q}$ (Rational set) -
\C
$\rightarrow \mathbb{C}$ (Complex set) -
\epsilon
$\rightarrow \varepsilon$ (varepsilon)
Metadata
If this bundle is loaded, it will automatically fill in the metadata fields of the pdf, like the title, subject, keywords etc.
Periodical
Add various elements relating to documents that are periodicals, like a newspaper. Should be called before \begin{document}
.
\cost{\$9.99}
Add a price tag.\issue{123}
Add in issue number.\location{Copenhagen}
Add a location specifier.\volume{123}
Add a volume number.
Publish
Add various elements relating to documents that are published in book-form, like a novel. Should be called before \begin{document}
.
\dedicate{dedicatee}{message}
Dedicate your document to someone, along with an optional message.\edition{123}{year}
Specify the edition of the document and the year it was published.\note{longer author's note}
Add an author's note.\publisher{your publishing company}
Specify the publisher of your document.\thank{people or organizations}
Thank someone in your document.\epigraph{poem or quotation}
Add a short paragraph of informal text that suggests the theme of the book.\endpages{N}{M}
Add N blank pages to the start and optionally M blank pages to the end of the document. This is mostly useful when printing and binding the document into a book.
In-class commands (for creating custom classes): \addFrontCover
, \addBackCover
, \addFormalPage
, \addCorners
, \addBorders
, \addEpigraph
, \addBlanks
.
Ornaments
Add ornamental elements all pages of the document. Browse the types of ornaments are available in the documentation for the pgfornaments
package. Check out the poem class for a visual example.
\corners{ornament_id}{color!opacity}{width}{padding}
Add ornaments to all four corners of all pages. Only the ID is mandatory.\borders{ornament_id}{color!opacity}{width}{padding}
Add ornaments to all four sides of all pages. Only the ID is mandatory.
Refs
Reference internal elements and cite external sources from your bibliography.
\at{label}
Reference your figures, tables, math-blocks, headings, code-blocks, etc. using your own labels.\At{label}
Uppercase equivalent of \r.\cite{your_source}
As defined in your bibliography file.\bib{path/to/refs}{style}
Specify and print your bibliography in a given style.
Styles:abbrv
,acm
,alpha
,apalike
,ieeetr
,plain
,siam
,unsrt
Default tounsrt
(in order of appearance).
Do not include the.bib
extension when specifying the path.
Adding a*
to the command, i.e.\bib*{...}
will print the entire given bibliography, regardless of whether entries have been explicitly referenced in your document.
In-class commands:
\bibfont{\...}
Apply styling commands to the bibliography text.
Sign
Place signature fields in your document.
sign{name}{designation}
E.g. \sign{Nicklas Vraa}{CEO of the Universe}. To place multiple fields on the same line, don't leave a blank line between command calls.
Size
These are commands for setting up the basic layout characteristics of your document. Should be called before \begin{document}
.
-
\size{standard}{orientation}
Set the dimensions and orientation of your document by specifying standards. E.g \size{a4}{portrait}.ISO-A ISO-B ISO-C ANSI US Orientation a0
a1
...
a6
b0
b1
...
b6
c0
c1
...
c6
ansia
ansib
...
ansie
letter
executive
legal
portrait
landscape
Alternatively, use
\size{custom}{width}{height}
, e.g.\size{custom}{6in}{9in}
. -
\margins{top}{bot}{inner}{outer}
Alternatively, the margins may be specified as{all}
,{topbot}{innerouter}
,{top}{bot}{innerouter}
. When doing double-sided printing, the inner margin is often wider than the outer margin to allow for space to bind pages together. For single-sided printing and digital-only documents, the inner and outer margins are almost always equal.
Tables
There are three types. These three tables will cover 90% of your table-needs, but you have access to the full power of the tabularray package for more complicated tables. The &
symbol separates items and \\
separates rows. Caption is optional.
\tabs{label}{type}{
% Your table content.
}{caption}
Types:
cols
: Classic table, the top row acts as the header.rows
: The left-most column acts as the header.grid
: Both the top row and left-most column act as headers.
Formatting code for the table may also be given explicitly in the type field.
The LiX package and all classes work out-of-the-box with Overleaf. Simply include lix.sty
and the appropriate .cls
file in your project folder.
If you are working locally, you need to have all package dependencies installed. Depending on which bundles are imported and what class is in use, LiX may import the following packages:
amsfonts, amsmath, amssymb, babel, caption, cite, doclicense, ebgaramond, enumitem, esint, eso-pic,, fancyhdr, float, fontenc, geometry, gothic, graphicx, GS1, hyperref, inconsolata, inputenc, lastpage, lettrine, lipsum, listings, microtype, multicol, numspell, parskip, pgfornaments, setspace, silence, siunitx, svg, tabularray, titlesec, titletoc, titling, tocbibind, ulem, xcolor, xparse, yfonts
Check up on the svg package, which has non-latex dependencies. If you have svg's included in your document, the compiler has to be run with the argument: --shell-escape
.
For VSCode, I recommend installing the LaTeX Workshop extension, and adding this snippet file to your snippets collection, and this entry to your own settings.json
file.
The following are bash commands that call scripts which are particularly useful for self-publishing and book production.
Encrypt and protect your PDF with a user- and owner-password for more secure distribution. Supply passwords and paths to source and destination. Requires qpdf
.
qpdf --encrypt <userpass> <ownerpass> 256 --modify=none --extract=n --print=none -- <source>.pdf <dest>.pdf
Prepare your PDF for book-style printing by performing automatic imposition. Supply the number of pages per signature N
, the sheet dimensions, and paths to source and destination. Requires pdfjam
.
pdfjam --nup 2x1 --signature <N> --frame false --twoside --trim '0cm 0cm 0cm 0cm' --clip true --quiet --keepinfo --papersize '{<height>,<2*width>}' --tidy --landscape --longedge --outfile <dest>.pdf <source>.pdf
LiX package:
- Watermark command.
- Add ornamental commands.
- Debug
\authors
command to ensure proper formatting of multiline input. - Further simplify table syntax. Use
|
instead of&
. - Add more types of tables to
\tabs
. - Add optional argument to
\toc
for specifying sorting order. - Revision command.
Classes:
- Research Paper
- Textbook
- Formal Contract
- Newspaper
- Novel
- Novella
- IEEE Journal/transactions
- Modern IEEE Research Paper
- Thesis
- Poem
- Presentation
- Handin
Additional:
- Syntax highlighter for VSCode using a grammar injection.
LEGAL NOTICE: This repository, including any and all of its forks and derivatives, may NOT be used in the development or training of any machine learning model of any kind, without the explicit permission of the owner of the original repository.