LaTeX

I typeset all of my notes and homework in LaTeX, using Vim as my text editor, with the VimTeX plugin for Vim+LaTeX incorporation, and the Ultisnips plugin for fast snippets while typesetting. All my diagrams are typeset with the TikZ and PGFPlots packages manually.

Inspiration to move over to Vim for LaTeX documents came from Gilles Castel's amazing blog post about his workflow. Most of my initial snippets were taken directly from this post, and I built up many others over time.


Tips

LaTeX can be hard to get used to, and has a decent learning curve. My largest tip is just to keep practicing—you'll only get better by continuously typesetting documents. I've only just gotten to the point where I can typeset live during lectures, and I've spent the past 2 years getting used to LaTeX and finding my own workflow.

Another huge tip is to Google everything you get stuck on as you typeset—eventually, you'll find yourself remembering more and more commands and environments, slowly getting over that learning curve.

Typesetting is very time consuming as you're starting out—be patient! You'll slowly build up speed and familiarity as you go, so don't immediately give up if you find that typesetting homeworks takes twice as long as writing everything by hand (or longer).


Custom Preamble

Here is a link to my current preamble.sty file, and here is a link to a minimal version of the physics package that I compiled from the package sources, containing only the \qty command and the modified math commands. My preamble is always evolving as I typeset more, and I will periodically update the version on this page.

Note: it is not the best idea to use my preamble as-is, if you are looking for a long-term solution; you'll likely have no idea which packages are included and how to use any of the commands/environments I've defined.

I suggest using my preamble as inspiration for what to include in your preamble, or how to structure your custom preamble—this way, you'll know exactly what you're doing, and you'd have full control over what packages to add to suit your needs.

I provide my preamble and full documentation in hopes that I can help others in the process of learning LaTeX, and ease their transition into typesetting. The purpose of sharing my preamble is to give a supplement for learning, not as a drop-in default preamble. Thus, I highly suggest you read through the source code yourself and adapt it to your needs, referencing the below documentation if necessary to clarify any details.


Usage

You may include this preamble within your documents with \usepackage[flags]{preamble}. To make the preamble.sty file available globally, put the file in ~/texmf/tex/latex/ (you may have to update your settings in your local TeX distribution); I have it as ~/texmf/tex/latex/styles/preamble.sty.

Here are the possible options that you can use with my preamble; you can include multiple, but flags specified later will override the previously specified flags. You can include the flags as \usepackage[flag1,flag2]{preamble}; here, flag2 will override flag1.


Groups
  • homework

    Enables: tikz, circuits, enumerate

    Initializes enumerate environments for homework typesetting, and includes all packages for diagram creation (TikZ, PGFPlots, and CircuiTikZ).

    If necessary, one can use the noenumerate flag to revert the enumerate changes.

  • lecture

    Enables: tikz, circuits, tcbtheorems, fancysections

    Initializes commands and theorem environments for typesetting lecture notes, and also includes all packages for diagram creation.

    The \lecture[date]{title} command is added to start lectures, and the example, definition, theorem, lemma and corollary environments are added as well, using colored boxes. All of these environments have optional arguments \begin{environment}[title][label]. Labels can be referenced by prefixing ex:, def:, thm:, lem: or cor: respectively to the label specified in the environment.

    Lists of theorems, definitions, etc. can be typeset with \listoflistname}. All list names are the environment names, with the prefix tcb; for example, to get a list of theorems, you would write \listoftcbtheorem.

    This is usually the group that includes the most packages and commands.

  • cheatsheet

    Enables: tikz, circuits, narrowmargins, cheatsheetlengths, smallercomponents

    Initializes page margins (narrower margins) and spacing for cheatsheet creation. Also includes all packages for diagram creation.

    Best used with the multicols environment to include two columns in the cheatsheet. See the cheatsheets linked on the coursework page for reference.

  • beamer

    Enables: tikz, circuits

  • Changes package settings to be compatible with the beamer document class. I don't use beamer too much at all, so I may update the preamble at some point breaking this flag.

Options
  • tikz, notikz

    Default: enabled

    Includes or excludes the TikZ and PGFPlots packages, respectively.

    If set, the CircuiTikZ package will automatically be loaded, and the circuits flag will do nothing.

    If unset, the CircuiTikZ package will never be loaded, even if the circuits flag is set.

  • circuits, nocircuits

    Default: disabled

    Includes or excludes the CircuiTikZ package, respectively.

    The latter is most commonly used in [tikz,nocircuits] to include TikZ but exclude CircuiTikZ.

  • tcbtheorems, notcbtheorems

    Default: disabled

    Initializes theorem environments with the tcolorbox package, making them fancier than the default environments.

    Most commonly excluded if there is no need to define any theorems in lecture notes; in this case, [lecture,notcbtheorems] would be used.

  • narrowmargins

    Default: disabled

    Makes the margins smaller (0.6 inches instead of the default 1 inch).

  • fancysections, nofancysections

    Default: disabled

    Defines the \lecture[date]{title} command for fancier lecture headers.

  • smallercomponents

    Default: disabled

    Decreases the size of CircuiTikZ components to 80%.

  • minted

    Default: disabled

    Includes the minted package.

    Provides syntax highlighting for code listings. Requires the Pygments package to be installed in the system Python interpreter.

    The Pygments style used is my custom port of the Atom One Light color scheme, and will fallback to the default Pygments style if not installed. Additionally, in homework answer environments, the background color of minted code blocks is changed to a light blue to differentiate between answer code blocks and problem statement code blocks.

  • pgfexternal

    Default: disabled

    Externalizes all TikZ figures.

    TikZ ships with the external library, which saves all TikZ diagrams as their own separate files in an auxiliary directory, so that they can be loaded in a lot quicker in continuous compilation. This flag enables this package, while also setting some internal options to ensure that all auxiliary files are put in the correct directory.

    Internally, there is a hard-coded \auxdir value, set to out; this should be the outer directory in which all external figures are stored. Figures are stored in an inner directory, named by the original .tex file.

  • asymptote

    Default: disabled

    Includes the asymptote package. This is not included by default with any of the groups, and requires the external asymptote program to be installed.

    A fair warning that the Asymptote documentation is quite bad, and I've spent countless hours trying to make sense of the options. Since then, I've fully switched over to using TikZ for diagram creation.

  • nominipagerestore

    Default: enabled

    Restores the \parskip length in minipage environments.

    By default, minipage environments resets the \parskip length to zero, which can cause some uneven formatting. This setting restores the \parskip value inside minipage environments, and is enabled by default.

    There shouldn't really be a reason why you'd disable this, unless you prefer the modified \parskip value.

  • times

    Default: disabled

    Overrides the font settings to use Times New Roman fonts.

    The default font I use in my LaTeX documents is Utopia font from Adobe, through the Utopia package.

    However, some people may prefer Times New Roman (which is the font I've used prior to switching over to Utopia), and this setting allows for a clean and seamless switch.

    There are a few internal changes regarding certain symbols and commands that are present in one font and not the other; a fair warning that these differences are not all covered, as I don't typically use this setting anymore.