A Simple Example for ME EN 575
Author
Andrew
Last Updated
9 yıl önce
License
Creative Commons CC BY 4.0
Abstract
A basic starter example to help students see examples of useful packages, math environments, figures, subfigures, tables, etc.
A basic starter example to help students see examples of useful packages, math environments, figures, subfigures, tables, etc.
\documentclass{article}
% --- load packages ---
\usepackage[margin=1in]{geometry} % change the margins
\usepackage{amsmath} % useful math environments and commands like align
\usepackage[colorlinks,bookmarks,bookmarksnumbered,allcolors=blue]{hyperref} % hyperlinks between references
\usepackage{graphicx} % include images
\usepackage[caption=false]{subfig} % subfigures. false option prevents conflicts in caption styling with other packages
\usepackage{booktabs} % better tables
\usepackage[capitalise]{cleveref} % better referencing. uses cref.
\usepackage[section]{placeins} % sometimes useful to prevent figures from floating out of a section
\usepackage{cite} % handles multiple citations in one command better
\usepackage{doi} % allow correct hypderlinking of DOIs
\begin{document}
\title{A Simple Example}
\author{Andrew Ning}
% put in \date{} if you don't want a date to appear, or enter a specific date, otherwise default is today's date.
\maketitle
\section*{Abstract}
This section is not numbered (see the star) as would be appropriate for something like an abstract.
\section{Introduction}
Note that \cref{eq:something} is numbered (and hyperlinked)
\begin{equation}
c_l(\alpha) = 2 \pi \alpha
\label{eq:something}
\end{equation}
but this one is not.
\begin{equation*} % note the star
\int_{-\infty}^\infty f(x) = \frac{3}{x^2}
\end{equation*}
This is an alternative syntax to have unnumbered equations
\[ \alpha \beta = 5 \gamma\]
You can also have equations inline like $4 \delta^2$. We can also align equations:
\begin{equation}
\begin{aligned}
\text{minimize} & \quad J(x) \\
\text{with respect to} & \quad x \\
\text{subject to} & \quad c(x) \le 0 \\
\end{aligned}
\end{equation}
Or align, but number each one separately:
\begin{align}
x &= 5\\
y + 2 &= 7\\
z + 4 &= x + 7
\end{align}
\Cref{fig:rosen} is showing how to insert, size, caption, and reference a figure. Note that I used a capital Cref for the start of sentence, and would use a lower case cref to refer to the figure in a sentence (\cref{fig:rosen}). Also note that I have used a vector-based image (pdf in this case). This is strongly preferred to bitmap images (png, jpg) if possible.
\begin{figure}[htbp]
\centering
\includegraphics[width=3.5in]{rosenbrock} % extension not needed
\caption{This are contour lines from the Rosenbrock function.}
\label{fig:rosen}
\end{figure}
The figure will float around the text as needed to get a well-typeset document.
\subsection{Hello}
This is a subsection. It contains an unordered list
\begin{itemize}
\item something
\item another thing
\item i don't know
\end{itemize}
and an ordered list
\begin{enumerate}
\item first time
\item second time
\item third time
\end{enumerate}
These can also be nested.
\subsection{Subfigure Subsection}
In \cref{fig:sub} you can see a subfigure example, I can also refer to part of the figure if I want (\cref{fig:sub1}).
\begin{figure}[htbp]
\centering
\subfloat[first subcaption]{
\includegraphics[width=0.45\textwidth]{rosenbrock}
\label{fig:sub1}
}
\qquad
\subfloat[second subcaption]{
\includegraphics[width=0.45\textwidth]{rosenbrock}
\label{fig:sub2}
}
\caption{Overall caption, which should be a sentence.}
\label{fig:sub}
\end{figure}
\section{Conclusion}
You can \textbf{bold} or \emph{emphasize} as needed. Be sure to use ``quotation marks'' correctly (leading backticks, closing pair of single quotation marks). As we see in \cref{tab:mytable} something something.
\begin{table}[htb]
\centering
\caption{This is a table caption. Note that table captions go above tables, whereas figure captions go below figures.}
\label{tab:mytable}
\begin{tabular}{@{}lrr@{}}
\toprule
& a column & another column \\
\midrule
case 1 & 1.30 & 2.30 \\
case 2 & 4.56 & 6.78 \\
\bottomrule
\end{tabular}
\end{table}
This is a regular-dash, an en--dash, and an em---dash. I'm citing an article \cite{article} and a book \cite{book} in this sentence using the attached BibTeX file.
% This is for the bibliography. Note that it is using sample.bib
% you would need to provide your own bibtex file.
\bibliographystyle{unsrt}
\bibliography{sample}
\end{document}