Personal tools
User menu

Knowledge Base/Tools/LaTeX

From Thalesians

Jump to: navigation, search

Contents

A minimalistic LaTeX article

The following article can be used as a template for your own articles:

\documentclass[12pt]{article}

\usepackage{amsmath}

\title{Welcome to \LaTeX}
\author{Paul Bilokon}
\date{17 June, 2009}

\begin{document}

\maketitle

\begin{abstract}
A sample article.
\end{abstract}

This is a \textbf{very} \textit{simple} Hello \LaTeX document!

\section{Option Pricing}

\subsection{Black-Scholes}

Here are some formul{\ae} from \cite{Black1973}:

\begin{align*}
d_1 &= \frac{\ln(S/K) + (r + \sigma^2/2)(T - t)}{\sigma \sqrt{T - t}}, \\
d_2 &= d_1 - \sigma \sqrt{T - t}.
\end{align*}

\begin{thebibliography}{99}
\bibitem{Black1973} \textsc{Black, F. and Scholes, M.} The Pricing of
Options and Corporate Liabilities. \emph{Journal of Political
Economics}, 81 (1973), 637--659.
\end{thebibliography}

\end{document}

Including bibliography entries stored in a file

If your bibliography file is called foobar.bib and is located in the same directory as your *.tex file, you can add the following

\bibliographystyle{plain}
\bibliography{foobar}

just before

\end{document}

Including bibliography entries even if they are not cited

Add

\nocite{*}

just before your bibliography inclusion, i.e. something like this:

\nocite{*}
\bibliographystyle{plain}
\bibliography{foobar}

% These lines come just before...

\end{document}

The command \nocite{*} causes LaTeX to include every entry in your .bib file.

Putting a copyright (registered, trademark) sign in Failed to parse (unknown function\LaTeX): \LaTeX

The registered ®, copyright ©, and trademark ™ signs can be inserted as follows:

Widget\textsuperscript{\textcopyright}

Widget\textsuperscript{\textregistered}

Widget\textsuperscript{\texttrademark}

Note that these are inserted in text mode, not maths, so there are no $s. \textsuperscript ensures that the signs appear in superscript, as it is usually required. However, for copyright ©, you may often need something like this:

Copyright \textcopyright Paul Bilokon, 2007.

"Not a subset" looks strange

If your  \not\subseteq looks strange, try replacing

\not{\subseteq}

with

\not\subseteq

Two equations on one line

Sometimes you may wish to put two equations on one line separating them by appropriate horizontal spacing. You can achieve this as follows:

\begin{equation}
\frac{dN}{dt} = a(t) N(t), \quad N(0) = N_0 \text{(constant)},
\label{eq:population-growth-model}
\end{equation}

Here \quad is responsible for the spacing.

What do I need to do in order to use \mathbb

For example, \mathbb{R} looks like  \mathbb{R} (reals); \mathbb{N} looks like  \mathbb{N} (natural numbers).

In order to use it,

\usepackage{amsfonts}

How to cite a particular chapter, section, etc.

Like so:

\cite[Section~1.3]{bierens-2004}

How to include URLs in the bibliography

Use the url package by Donald Arseneau.

In the preamble:

\usepackage{url}

In a BibTeX entry:

@misc{
    c.elmohamed,
    author = "Saleh Elmohamed",
    title = "Examples in {H}igh {P}erformance {F}ortran",
    howpublished = "Website",
    year = {1996},
    note = {\url{http://www.npac.syr.edu/projects/
                    cpsedu/summer98summary/ examples/hpf/hpf.html}}
}

For more information, see this tip by Leo Breebaart.

Defining and using "variables"

To define:

\def \LectureTitle {Discrete Dynamical Systems}
\def \LectureNumber {2}

To use:

\title{\LectureTitle}
\subtitle{Lecture \LectureNumber}

Diagonal argument

Here is one way to express the diagonal argument (something like this) in Failed to parse (unknown function\LaTeX): \LaTeX

\begin{tabular}{cccccccccccc}
  $I_1^1$      & $\rightarrow$ & $I_2^1$  &            & $I_3^1$  & $\rightarrow$ & $I_4^1$  &            & $I_5^1$  & $\rightarrow$ & $I_6^1$  & $\cdots$ \\
               & $\swarrow$    &          & $\nearrow$ &          & $\swarrow$    &          & $\nearrow$ &          & $\swarrow$    &          &          \\
  $I_1^2$      &               & $I_2^2$  &            & $I_3^2$  &               & $I_4^2$  &            & $I_5^2$  &               & $I_6^2$  & $\cdots$ \\
  $\downarrow$ & $\nearrow$    &          & $\swarrow$ &          & $\nearrow$    &          & $\swarrow$ &          & $\nearrow$    &          &          \\
  $I_1^3$      &               & $I_2^3$  &            & $I_3^3$  &               & $I_4^3$  &            & $I_5^3$  &               & $I_6^3$  & $\cdots$ \\
               & $\swarrow$    &          & $\nearrow$ &          & $\swarrow$    &          & $\nearrow$ &          & $\swarrow$    &          &          \\
  $I_1^4$      &               & $I_2^4$  &            & $I_3^4$  &               & $I_4^4$  &            & $I_5^4$  &               & $I_6^4$  & $\cdots$ \\
  $\downarrow$ & $\nearrow$    &          & $\swarrow$ &          & $\nearrow$    &          & $\swarrow$ &          & $\nearrow$    &          &          \\
  $I_1^5$      &               & $I_2^5$  &            & $I_3^5$  &               & $I_4^5$  &            & $I_5^5$  &               & $I_6^5$  & $\cdots$ \\
  $\vdots$     &               & $\vdots$ &            & $\vdots$ &               & $\vdots$ &            & $\vdots$ &               & $\vdots$ &          \\
\end{tabular}
  • This page was last modified on 11 November 2011, at 22:25.
  • This page has been accessed 26,896 times.