The best way to learn LaTeX is by writing your own code and working through different situations. In this section of the guide there are several samples problems, as well as their solutions. The problems build off the previous ones and tend to get harder as you move along. Remember there can be more than one way to answer some of these questions so if your solution doesn't match what is given but the code compiles correctly that is ok.
Keep practicing!
Create a document with the title Hello World!, your name, and todays date. Include in the document the following text "Hello World! Today I am learning LaTeX." The solution should look like this (but with todays date):
\documentclass{article}
\title{Hello World!}
\author{Your Name}
\date{January 1, 1831}
\begin{document}
\maketitle
\textbf{Hello World!} Today I am learning \LaTeX.
\end{document}
Add to the document you created in exercise 1 the following text:
"LaTeX is a great program for writing math. I can write in line math such as a^2 + b^2 = c^2. I can also give equations their own space: gamma^2 +theta^2 = omega^2"
Your final document should look like this:
\documentclass{article}
\title{Hello World!}
\author{Your Name}
\date{January 1, 1831}
\begin{document}
\maketitle
\textbf{Hello World!} Today I am learning \LaTeX. \LaTeX{} is a great program for writing math. I can write in line math such as $a^2+b^2=c^2$. I can also give equations their own space: \[ \gamma^2+\theta^2=\omega^2\]
\end{document}
In this exercise you will build onto the document created in exercises 1 and 2 with more complicated math and structures. This is a much more difficult exercise so take your time.
First give the display environment equation from exercise 2 an equation number. Second add the following line of text (make sure there it is not indented as a new paragraph:
"Maxwell's equations" are named for James Clark Maxwell and are as follow:
Now write Maxwell's equations (as seen below), use an align environment and align the equations at the = signs and at the equations names.
\documentclass{article}
\usepackage{amsmath}
\title{Hello World!}
\author{Your Name}
\date{January 1, 1831}
\begin{document}
\maketitle
\textbf{Hello World!} Today I am learning \LaTeX. \LaTeX{} is a great program for writing math. I can write in line math such as $a^2+b^2=c^2$. I can also give equations their own space:
\begin{equation}
\gamma^2+\theta^2=\omega^2
\end{equation}
``Maxwell's equations'' are named for James Clark Maxwell and are as follow:
\begin{align}
\vec{\nabla} \cdot \vec{E} \quad &=\quad\frac{\rho}{\epsilon_0} &&\text{Gauss's Law} \\
\vec{\nabla} \cdot \vec{B} \quad &=\quad 0 &&\text{Gauss's Law for Magnetism}\\
\vec{\nabla} \times \vec{E} \quad &=\hspace{10pt}-\frac{\partial{\vec{B}}}{\partial{t}} &&\text{Faraday's Law of Induction} \\
\vec{\nabla} \times \vec{B} \quad &=\quad \mu_0\left( \epsilon_0\frac{\partial{\vec{E}}}{\partial{t}}+\vec{J}\right) &&\text{Ampere's Circuital Law}
\end{align}
\end{document}
Labels and reference are very simple to execute in LaTeX, can be used with any numbered object such as figures, equations, and sections, and are automatically updated whenever the document is complied. If, for example, you realized you forgot an equation somewhere in the middle of your document, between 10 other equations, all the equations after the newly inserted equation would automatically be renumbered and proper references to them will reflect this new numbering!
For this exercise take the document made in the previous exercise and create two sections one at the beginning (Getting Started) and one after all your texts (What about Matrix Equations?). Also add to your document references to each of Maxwell's Equations, and then write a sentence that references each equation. You will need to use the commands \label{} and \ref{}.
It is common practice in LaTeX when labeling to use the format eq:name, fig:name, tab:name, and so on depending on the type of object you are labeling. If you are confused by this look at the labels in the solution
Also, if you would like your citations to act as hyperlinks you need to use the package hyperref, \usepackage{hyperref}, remember with this package you can change the default hyperlink settings with the command \hypersetup{} in the preamble i.e. \hypersetup{colorlinks=true, linkcolor=blue, urlcolor=blue, citecolor=blue}.
\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue, urlcolor=blue, citecolor=blue}
\title{Hello World!}
\author{Your Name}
\date{January 1, 1831}
\begin{document}
\maketitle
\section{Getting Started}
\textbf{Hello World!} Today I am learning \LaTeX. \LaTeX{} is a great program for writing math. I can write in line math such as $a^2+b^2=c^2$. I can also give equations their own space:
\begin{equation}
\gamma^2+\theta^2=\omega^2
\end{equation}
``Maxwell's equations'' are named for James Clark Maxwell and are as follow:
\begin{align}
\vec{\nabla} \cdot \vec{E} \quad &=\quad\frac{\rho}{\epsilon_0} &&\text{Gauss's Law} \label{eq:GL}\\
\vec{\nabla} \cdot \vec{B} \quad &=\quad 0 &&\text{Gauss's Law for Magnetism} \label{eq:GLM}\\
\vec{\nabla} \times \vec{E} \quad &=\hspace{10pt}-\frac{\partial{\vec{B}}}{\partial{t}} &&\text{Faraday's Law of Induction} \label{eq:FL}\\
\vec{\nabla} \times \vec{B} \quad &=\quad \mu_0\left( \epsilon_0\frac{\partial{\vec{E}}}{\partial{t}}+\vec{J}\right) &&\text{Ampere's Circuital Law} \label{eq:ACL}
\end{align}
Equations \ref{eq:GL}, \ref{eq:GLM}, \ref{eq:FL}, and \ref{eq:ACL} are some of the most important in Physics.
\section{What about Matrix Equations?}
\end{document}
In this exercise add the matrix equation to your document as seen below:
\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue, urlcolor=blue, citecolor=blue}
\title{Hello World!}
\author{Your Name}
\date{January 1, 1831}
\begin{document}
\maketitle
\section{Getting Started}
\textbf{Hello World!} Today I am learning \LaTeX. \LaTeX{} is a great program for writing math. I can write in line math such as $a^2+b^2=c^2$. I can also give equations their own space:
\begin{equation}
\gamma^2+\theta^2=\omega^2
\end{equation}
``Maxwell's equations'' are named for James Clark Maxwell and are as follow:
\begin{align}
\vec{\nabla} \cdot \vec{E} \quad &=\quad\frac{\rho}{\epsilon_0} &&\text{Gauss's Law} \label{eq:GL}\\
\vec{\nabla} \cdot \vec{B} \quad &=\quad 0 &&\text{Gauss's Law for Magnetism} \label{eq:GLM}\\
\vec{\nabla} \times \vec{E} \quad &=\hspace{10pt}-\frac{\partial{\vec{B}}}{\partial{t}} &&\text{Faraday's Law of Induction} \label{eq:FL}\\
\vec{\nabla} \times \vec{B} \quad &=\quad \mu_0\left( \epsilon_0\frac{\partial{\vec{E}}}{\partial{t}}+\vec{J}\right) &&\text{Ampere's Circuital Law} \label{eq:ACL}
\end{align}
Equations \ref{eq:GL}, \ref{eq:GLM}, \ref{eq:FL}, and \ref{eq:ACL} are some of the most important in Physics.
\section{What about Matrix Equations?}
\begin{equation*}
\begin{pmatrix}
a_{11}&a_{12}&\dots&a_{1n}\\
a_{21}&a_{22}&\dots&a_{2n}\\
\vdots&\vdots&\ddots&\vdots\\
a_{n1}&a_{n2}&\dots&a_{nn}
\end{pmatrix}
\begin{bmatrix}
v_{1}\\
v_{2}\\
\vdots\\
v_{n}
\end{bmatrix}
=
\begin{matrix}
w_{1}\\
w_{2}\\
\vdots\\
w_{n}
\end{matrix}
\end{equation*}
\end{document}
For this exercise create a new section to your document for figures and tables. In that section create a table and a figure. Give each object a caption, try putting the table caption above the table and the figure caption below. Try this with a figure of your choice.
\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue, urlcolor=blue, citecolor=blue}
\usepackage{graphicx}
\title{Hello World!}
\author{Your Name}
\date{January 1, 1831}
\begin{document}
\maketitle
\section{Getting Started}
\textbf{Hello World!} Today I am learning \LaTeX. \LaTeX{} is a great program for writing math. I can write in line math such as $a^2+b^2=c^2$. I can also give equations their own space:
\begin{equation}
\gamma^2+\theta^2=\omega^2
\end{equation}
``Maxwell's equations'' are named for James Clark Maxwell and are as follow:
\begin{align}
\vec{\nabla} \cdot \vec{E} \quad &=\quad\frac{\rho}{\epsilon_0} &&\text{Gauss's Law} \label{eq:GL}\\
\vec{\nabla} \cdot \vec{B} \quad &=\quad 0 &&\text{Gauss's Law for Magnetism} \label{eq:GLM}\\
\vec{\nabla} \times \vec{E} \quad &=\hspace{10pt}-\frac{\partial{\vec{B}}}{\partial{t}} &&\text{Faraday's Law of Induction} \label{eq:FL}\\
\vec{\nabla} \times \vec{B} \quad &=\quad \mu_0\left( \epsilon_0\frac{\partial{\vec{E}}}{\partial{t}}+\vec{J}\right) &&\text{Ampere's Circuital Law} \label{eq:ACL}
\end{align}
Equations \ref{eq:GL}, \ref{eq:GLM}, \ref{eq:FL}, and \ref{eq:ACL} are some of the most important in Physics.
\section{What about Matrix Equations?}
\begin{equation*}
\begin{pmatrix}
a_{11}&a_{12}&\dots&a_{1n}\\
a_{21}&a_{22}&\dots&a_{2n}\\
\vdots&\vdots&\ddots&\vdots\\
a_{n1}&a_{n2}&\dots&a_{nn}
\end{pmatrix}
\begin{bmatrix}
v_{1}\\
v_{2}\\
\vdots\\
v_{n}
\end{bmatrix}
=
\begin{matrix}
w_{1}\\
w_{2}\\
\vdots\\
w_{n}
\end{matrix}
\end{equation*}
\section{Tables and Figures}
Creating a Table is not unlike creating a matrix:
\begin{table}[hbt!]
\centering
\caption{This is a table that shows how to create different lines as well as different justifications}
\begin{tabular}{|l||c|c|r|}
\hline
$x$&1&2&3\\
\hline
$f(x)$&4&8&12\\
f(x)&4&8&12\\
\hline
\end{tabular}
\end{table}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{bern}
\caption{Bern Dibner Library}
\end{figure}
\end{document}
Before attempting this exercise make sure you have read through the BibTex tab of this guide.
Create a BibTex file with a few citations in it. Add a sentence that contains these citations and then add a bibliography to your document.
\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue, urlcolor=blue, citecolor=blue}
\usepackage{graphicx}
\title{Hello World!}
\author{Your Name}
\date{January 1, 1831}
\begin{document}
\maketitle
\section{Getting Started}
\textbf{Hello World!} Today I am learning \LaTeX. \LaTeX{} is a great program for writing math. I can write in line math such as $a^2+b^2=c^2$. I can also give equations their own space:
\begin{equation}
\gamma^2+\theta^2=\omega^2
\end{equation}
``Maxwell's equations'' are named for James Clark Maxwell and are as follow:
\begin{align}
\vec{\nabla} \cdot \vec{E} \quad &=\quad\frac{\rho}{\epsilon_0} &&\text{Gauss's Law} \label{eq:GL}\\
\vec{\nabla} \cdot \vec{B} \quad &=\quad 0 &&\text{Gauss's Law for Magnetism} \label{eq:GLM}\\
\vec{\nabla} \times \vec{E} \quad &=\hspace{10pt}-\frac{\partial{\vec{B}}}{\partial{t}} &&\text{Faraday's Law of Induction} \label{eq:FL}\\
\vec{\nabla} \times \vec{B} \quad &=\quad \mu_0\left( \epsilon_0\frac{\partial{\vec{E}}}{\partial{t}}+\vec{J}\right) &&\text{Ampere's Circuital Law} \label{eq:ACL}
\end{align}
Equations \ref{eq:GL}, \ref{eq:GLM}, \ref{eq:FL}, and \ref{eq:ACL} are some of the most important in Physics.
\section{What about Matrix Equations?}
\begin{equation*}
\begin{pmatrix}
a_{11}&a_{12}&\dots&a_{1n}\\
a_{21}&a_{22}&\dots&a_{2n}\\
\vdots&\vdots&\ddots&\vdots\\
a_{n1}&a_{n2}&\dots&a_{nn}
\end{pmatrix}
\begin{bmatrix}
v_{1}\\
v_{2}\\
\vdots\\
v_{n}
\end{bmatrix}
=
\begin{matrix}
w_{1}\\
w_{2}\\
\vdots\\
w_{n}
\end{matrix}
\end{equation*}
\section{Tables and Figures}
Creating a Table is not unlike creating a matrix:
\begin{table}[h!]
\centering
\caption{This is a table that shows how to create different lines as well as different justifications}
\begin{tabular}{|l||c|c|r|}
\hline
$x$&1&2&3\\
\hline
$f(x)$&4&8&12\\
f(x)&4&8&12\\
\hline
\end{tabular}
\end{table}
\begin{figure}[h!]
\centering
\includegraphics[width=\textwidth]{bern}
\caption{Bern Dibner Library}
\end{figure}
\section{Bibliography}
You will probably want references in your document so that you can cite articles like \cite{frenkel_fine_2013, frenkel_optical_2013, frenkel_temperature_2012, frenkel_whispering-gallery_2013,frenkel_-chip_2016}
\bibliographystyle{ieeetr}
\bibliography{bibl}
\end{document}
The following is the BibTex file bibl.bib created using Zotero:
@inproceedings{frenkel_fine_2013,
title = {Fine temperature measurement and fabrication of on-chip whispering-gallery mode micro-sensors},
url = {http://proxy.library.nyu.edu/login?url=http://search.ebscohost.com/login.aspx?direct=true&db=edselc&AN=edselc.2-52.0-84901804547&site=eds-live},
doi = {10.1115/MNHMT2013-22003},
booktitle = {{ASME} 2013 4th {International} {Conference} on {Micro}/{Nanoscale} {Heat} and {Mass} {Transfer}, {MNHMT} 2013},
publisher = {American Society of Mechanical Engineers (ASME)},
author = {Frenkel, M. and Avellan, M. and Guo, Z.},
year = {2013},
note = {Conference Proceedings}
}
@inproceedings{frenkel_optical_2013,
title = {Optical whispering-gallery mode phenomenon as a composite sensor with applications to direct on-chip thermal sensing},
volume = {4},
isbn = {978-0-7918-5550-8},
url = {http://proxy.library.nyu.edu/login?url=http://search.ebscohost.com/login.aspx?direct=true&db=edselc&AN=edselc.2-52.0-84893001861&site=eds-live},
doi = {10.1115/HT2013-17245},
booktitle = {{ASME} 2013 {Heat} {Transfer} {Summer} {Conf}.{Collocated} with the {ASME} 2013 7th {Int}.{Conf}.on {Energy} {Sustainability} and the {ASME} 2013 11th {Int}.{Conf}.on {Fuel} {Cell} {Science}, {Engineering} and {Technology}, {HT} 2013},
author = {Frenkel, M. and Avellan, M. and Guo, Z.},
year = {2013},
note = {Conference Proceedings}
}
@inproceedings{frenkel_temperature_2012,
title = {Temperature sensing of joule heating inside an optical whispering-gallery mode micro-annulus},
volume = {2},
isbn = {978-0-7918-4478-6},
url = {http://proxy.library.nyu.edu/login?url=http://search.ebscohost.com/login.aspx?direct=true&db=edselc&AN=edselc.2-52.0-84892648569&site=eds-live},
doi = {10.1115/HT2012-58133},
booktitle = {{ASME} 2012 {Heat} {Transfer} {Summer} {Conf}.{Collocated} with the {ASME} 2012 {Fluids} {Engineering} {Div}.{Summer} {Meeting} and the {ASME} 2012 10th {Int}.{Conf}.on {Nanochannels}, {Microchannels} and {Minichannels}, {HT} 2012},
author = {Frenkel, M. and Avellan, M. and Guo, Z.},
year = {2012},
note = {Conference Proceedings},
pages = {823--826}
}
@article{frenkel_whispering-gallery_2013,
title = {Whispering-gallery mode composite sensors for on-chip dynamic temperature monitoring},
volume = {24},
issn = {09570233},
url = {http://proxy.library.nyu.edu/login?url=http://search.ebscohost.com/login.aspx?direct=true&db=edswsc&AN=000320449100036&site=eds-live},
abstract = {Whispering-gallery mode temperature microsensors have been demonstrated to have extremely high accuracy. Previous experiments have been limited to indirect sensor heating by externally heating the local environment. In this paper, we coated PDMS films directly onto an electrical resistive wire as sensors, allowing on-chip dynamic temperature measurement. The effects of sensor size are discussed and verified through an expansion of the current theory of WGM resonance shifts to include composite materials. Finally, the WGM sensor's measurements are compared to the same measurements recorded by a thermocouple, demonstrating the great advantages of WGM sensors for on-chip real temperature monitoring.},
number = {7},
journal = {MEASUREMENT SCIENCE AND TECHNOLOGY},
author = {Frenkel, M. and Avellan, M. and Guo, Z. X.},
year = {2013},
keywords = {ENGINEERING, MULTIDISCIPLINARY, INSTRUMENTS \& INSTRUMENTATION, on-chip measurement, optical sensor, temperature measurement}
}
@article{frenkel_-chip_2016,
title = {On-chip, dynamic, and cryogenic temperature monitoring via {PDMS} micro-bead coatings},
volume = {54},
issn = {1099-0488},
url = {http://dx.doi.org/10.1002/polb.24016},
doi = {10.1002/polb.24016},
abstract = {Polydimethylsiloxane (PDMS) microshells/beads coated onto an electrical current-carrying wire are demonstrated for on-chip, dynamic, cryogenic temperature measurement via monitoring optical whispering-gallery mode (WGM) frequency shifts. PDMS is found to be capable of supporting WGM resonance at cryogenic temperatures down to 95 K, limited by the present lab-built cryogenic working environment. The effect of the polymeric sensor diameter on temperature sensitivity is explored and discussed. The sensors are tested for their real-time temperature monitoring capabilities and accuracy in the cryogenic temperature regime of 95–140 K, and a comparison to a theoretical model, where the electrical resistivity of nichrome wire at cryogenic temperature is also experimentally determined, is examined. © 2016 Wiley Periodicals, Inc. J. Polym. Sci., Part B: Polym. Phys. 2016, 54, 1118–1124},
number = {12},
journal = {Journal of Polymer Science Part B: Polymer Physics},
author = {Frenkel, Matthew and Guo, Zhixiong},
year = {2016},
keywords = {coatings, cryogenic temperature, electrical resistivity, films, optical resonance, sensors},
pages = {1118--1124}
}
A) Trying creating the following calculus equation:
B) If you are feeling really good try your luck with these equations (no hints are given)
Hints for part A only
Part A
\[
\int\limits_a^b x\,dx = \left.\frac{x^2}{2} \right|_a^b
\]
Part B
\begin{equation}
\iiint\limits_V f(x,y,z)\,dV = F
\end{equation}
\begin{equation}
\frac{dx}{dy}=x'=\lim_{h \to 0}\frac{f(x+h)-f(x)}{h}
\end{equation}
\begin{equation}
|x|=\begin{cases}
-x, & \text{if $x < 0$}\\
x, & \text{if $x \geq 0$}
\end{cases}
\end{equation}
\begin{equation}
F(x)= A_0 + \sum_{n=1}^N\left[ A_n\cos{\left(\frac{2\pi nx}{P}\right)}+B_n\sin{\left(\frac{2\pi nx}{P}\right)}\right]
\end{equation}
\begin{equation}
\sum_n \frac{1}{n^s}=\prod_p \frac{1}{1-\frac{1}{p^s}}
\end{equation}
\begin{equation*} % equation* suppress equation numbering same for align*
m\ddot{x}+c\dot{x}+kx=F_0\sin(2\pi ft)
\end{equation*}
\begin{align*}
f(x)\quad &=\quad x^2 + 3x + 5x^2 +8 +6x\\
&=\quad 6x^2 +9x +8\\
&=\quad x(6x+9)+8
\end{align*}
$$
X=\frac{F_0}{k}\frac{1}{\sqrt{(1-r^2)^2+(2\zeta r)^2}}
$$
\begin{equation}
G_{\mu\nu} \equiv R_{\mu\nu}-\frac{1}{2}Rg_{\mu\nu}=\frac{8\pi G}{c^4}T_{\mu\nu}
\end{equation}\\
$$\mathrm{6CO_2+6H_2O \to C_6H_{12}O_6+6O_2}$$
$$\mathrm{SO_4^{2-}+Ba^{2+} \to BaSO_4 }$$
\begin{equation}
\begin{pmatrix}
a_{11}&a_{12}&\dots&a_{1n}\\
a_{21}&a_{22}&\dots&a_{2n}\\
\vdots&\vdots&\ddots&\vdots\\
a_{n1}&a_{n2}&\dots&a_{nn}
\end{pmatrix}
\begin{pmatrix}
v_{1}\\
v_{2}\\
\vdots\\
v_{n}
\end{pmatrix}
=
\begin{pmatrix}
w_{1}\\
w_{2}\\
\vdots\\
w_{n}
\end{pmatrix}
\end{equation}
\begin{equation}
\frac{\partial{\bf{u}}}{\partial{t}}+(\bf{u}\cdot\nabla)\bf{u}-\nu\nabla^2\bf(u)=-\nabla h
\end{equation}
\[ % This is preferred to the $$ environment
\alpha A \beta B \gamma \Gamma \delta \Delta \pi \Pi \omega \Omega
\]
In this exercise try your hand at creating a new command:
A) Create a command that will display a multiplication problem in the pictured format if you give it the two numbers to be multiplied
B) Can you adapt to code so that it will also display the answer, if provided
C) Can you code several rows of problems?
Part A
\documentclass[11pt]{article}
\usepackage{amsmath}
\newcommand{\mul}[2][]{
\quad\large{ \begin{tabular}{r}
\textbf{#2}\\
$\boldsymbol{\times}$ \textbf{#1}\\
\hline \vspace{3pt}\\
\vspace{10pt}\\
\end{tabular}
}}
\begin{document}
\mul{5}{8}
\end{document}
Part B
Part A
\documentclass[11pt]{article}
\usepackage{amsmath}
\newcommand{\mul}[3][]{
\quad\large{ \begin{tabular}{r}
\textbf{#3}\\
$\boldsymbol{\times}$ \textbf{#2}\\
\hline \vspace{3pt}
\textbf{#1}\\
\vspace{10pt}\\
\end{tabular}
}}
\begin{document}
\mul[40]{5}{8}
\end{document}
Part C
\documentclass[11pt]{article}
\usepackage{amsmath}
\newcommand{\mul}[3][]{
\quad\large{ \begin{tabular}{r}
\textbf{#3}\\
$\boldsymbol{\times}$ \textbf{#2}\\
\hline \vspace{3pt}
\textbf{#1}\\
\vspace{10pt}\\
\end{tabular}
}}
\begin{document}
\begin{tabular}{ccccccc}
\mul{5}{8} & \mul{4}{12} &\mul{3}{2}& \mul{10}{7} &\mul{5}{5}& \mul{6}{4}& \mul{8}{9}\\
\mul{12}{12}& \mul{4}{1}& \mul{9}{6}& \mul{7}{5} &\mul{5}{11}& \mul{8}{8}& \mul{7}{12}\\
\mul{5}{1}& \mul{3}{4}& \mul{6}{2}& \mul{5}{5}& \mul{9}{3}& \mul{1}{12}& \mul{0}{8}\\
\end{tabular}
\end{document}