Skip to content

Instantly share code, notes, and snippets.

@TommyPKeane
Created March 9, 2023 16:49
Show Gist options
  • Save TommyPKeane/d740af61083a3edd3af38f8440158280 to your computer and use it in GitHub Desktop.
Save TommyPKeane/d740af61083a3edd3af38f8440158280 to your computer and use it in GitHub Desktop.
Example of a standalone .tex file for a chapter in a LaTeX document, showing some various mathematical and typesetting features of the language.
% -*- coding: utf-8 -*-
%!TEX root = ../latex/Dissertation.tex
%% ! CHAPTER ! INTRODUCTION
% --------------------------------------------------------------------------------------------------
\chapter{Introduction}
\label{chap:Introduction}
Chapter text goes here. Indentation will be ignored, but it can be useful for you when you're
writing. The indentation helps to visually separate chapters and sections.
The first comment line is a standard indication of the this file's encoding format. For general
situations, it is almost always favorable to take advantage of the UTF-8 encoding, allowing the
embedding of non-english characters entered with non-english keyboards or key-combinations. Be
careful that \LaTeX{} itself may not render your non-english characters, at least without any
special packages. This may seem counter-intuitive, but that is because you need to think of the
text in your \LaTeX{} document not as written text, but as your \LaTeX{} code that will be
rendered into the written text/language. Defining non-english (non-ASCII) characters within the
programming language itself is only a relatively modern feature that is not widely implemented,
if at all.
The second comment line is the path to the main document where this chapter file will be brought
into it through an \texttt{input} command. By providing that ``perbang'' (percent-bang) or
``modbang'' (modulus-bang), you are providing a shell-like command similar to the ``hashbang''
(hashtag/shell/pound-bang) symbol used in shell scripts to indicate how a file should be called.
What the second comment helps with, the modbang statement, is that you can then use the \LaTeX{}
tools package (add-on) in Sublime Text to automatically find your main document bibliography.
Now whenever you type \texttt{cite} or \texttt{Cref}, you will be able to get a full autocomplete
list of references or chapters (respectively), even though you are writing from a completely
different document that makes no mention of the bibliography. That statement allows you to
essentially ``link'' these files together, understanding that it may be easier to manage a large
document (like a dissertation) with separate chapter files, but you want to render everything as
one document \textit{via} the chapter arrangement of the ``dissertation.tex'' file.
%% !! SECTION !! NEW NOMENCLATURE
% ----------------------------------------------------------------------------------------------
\section{Understanding the New Nomenclature}
\label{sec:Intro-Nomenclature}
Keep in mind that with \LaTeX{} there is no closing to any section or sub-component of a
document. Sections and chapters and sub-sections are only ended when you declare the
beginning of a new one.
This is why we like to use these comment dividers, because it better indicates the structure
of the document. But do not think that anything beyond the divider is no longer in the scope
of this section. Scope of sections (chapters, \textit{etc.}) only end when a new section is
declared.
%noitces ---------------------------------------------------------------------------------------
That means that this text will still be inside the ``nomenclature'' section. The comments are
only visual dividers, to help you as you write the document. You must be aware of the document's
layout and construction. This not only encourages you to be organized, but it helps as the code
will now look more like the rendered document. If you can not bridge that computational gap
between the text and code you write in your \LaTeX{} document and the vectorized, rendered
output, then you will most likely be frustrated with the rendering process.
%% !! SECTION !! EVEN MORE STUFF
% ----------------------------------------------------------------------------------------------
\section{Discovering Even More Stuff}
\label{sec:Intro-MoreStuff}
Note that if you want to actually create an internal scope, something like a block quote
with wider margins than the rest of the text, you can do so with the \texttt{adjustwidth}
environment command. Environments are the special names for \LaTeX{} elements that use the
\texttt{begin} and \texttt{end} syntax.
\begin{adjustwidth}{1em}{2em}
Here is a section of text that is indented by 1em on the left and 2em on the right.
You can create separate paragaphs and include figures, and do most things inside this
environment. It is essentially a temporary adjustment to the document margins and it
will persist across page-breaks.
\end{adjustwidth}
Now we are back to the normal margins.
Note that the ``em'' units represent the ``pt'' size of the current typeface structure
of the font in use. The font is the collection of symbols and the typeface is how those
symbols are visually rendered -- here, by \LaTeX{} and your commands. A ``pt'' (point)
unit is one seventy-second of an inch:
\begin{equation}
1 \left[pt\right] = \frac{1}{72} \left[in\right]
\end{equation}
This means that an $18 \left[pt\right]$ typeface has a baseline height of a quarter of
an inch. If the current typeface is set as such, then using the ``em'' units would be
to declare quarter-inch measures. If you change the rendered size of the font, then you
are implicitly changing the ``em'' units' size factor. So, you can think of ``em'' units
as font-relative units. Instead of a percentage of the document size, it is a percentage
of the current font-size, wherever it is declared.
Take careful note that this means that the ``em'' units are not document specific, they are
section specific. Whenever an ``em'' unit is declared, it is taken from the current font
size, no matter what the font size is anywhere else in the document. This may or may not be
your desired operation, so please be aware of the rendering.
%noitces ---------------------------------------------------------------------------------------
%retpahc -------------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment