The mcode package, for instance, is in:
~/Library/texmf/tex/latex/mcode
Now why doesn't the Mac OS search function find this file?
Showing posts with label LaTeX. Show all posts
Showing posts with label LaTeX. Show all posts
Thursday, February 9, 2012
Wednesday, January 11, 2012
Latex - more commands
I've been doing 3 problem sets/week in LaTeX for the last several weeks; here are some more tips to follow up on my previous post:
Making your own functions:
\newcommand{\norm}[1]{\left\Vert #1 \right\Vert}
\DeclareMathOperator*{\argmin}{arg\,min}
The * puts the subscript below the operator. To stack subscripts:
\min_{\substack{ X>0 \\ Z \\ W=W^* }}
Different vector formats
Underline, with the line crossing descenders (as in gjpqy):
\usepackage{soul}
\setuldepth{abcdef} % sets ul depth based on letters w/o descenders
\newcommand{\vecu}[1]{\text{\ul{$#1$}}\xspace}
Shortcuts that I've found useful:
\newcommand{\reals}{\ensuremath{\mathbb{R}}\xspace}
\def \ba#1\ea{\begin{align*}#1\end{align*}}
\newcommand{\ii}{^{-1}}
\newcommand{\intii}{\int_{-\infty}^{\infty}}
Matrix formatting
check out these posts from Stefan Kottwitz's excellent TeXblog
A cool trick to turn + - = into alignment marks (e.g. for systems of linear equations)
http://tex.stackexchange.com/questions/6965/multicol-layout-for-systems-of-linear-equations
Cool stuff with figures
http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions
MATLAB code
Get the mcode package, which configures the listings package use with MATLAB. The demo is pretty self-explanatory, and the package works great!
Miscellaneous:
Accent marks:
http://en.wikibooks.org/wiki/LaTeX/Accents
Found this while researching this post and learned a bunch of new things:
http://www.math.uiuc.edu/~hildebr/tex/basics.html
For example, use \eqref to put parentheses around the equation number.
To reduce vertical spacing around section headings: \usepackage[compact]{titlesec}
Cursive lowercase l, as in l2: \ell
Making your own functions:
\newcommand{\norm}[1]{\left\Vert #1 \right\Vert}
\DeclareMathOperator*{\argmin}{arg\,min}
The * puts the subscript below the operator. To stack subscripts:
\min_{\substack{ X>0 \\ Z \\ W=W^* }}
Different vector formats
Underline, with the line crossing descenders (as in gjpqy):
\usepackage{soul}
\setuldepth{abcdef} % sets ul depth based on letters w/o descenders
\newcommand{\vecu}[1]{\text{\ul{$#1$}}\xspace}
Bold:
\newcommand{\vecb}[1]{\ensuremath{\boldsymbol{#1}}\xspace}
And one more layer of shortcut/indirection (overwrites the caron diacritic)
\renewcommand{\v}[1]{\vect{#1}}
Shortcuts that I've found useful:
\newcommand{\reals}{\ensuremath{\mathbb{R}}\xspace}
\def \ba#1\ea{\begin{align*}#1\end{align*}}
\newcommand{\ii}{^{-1}}
\newcommand{\intii}{\int_{-\infty}^{\infty}}
Matrix formatting
check out these posts from Stefan Kottwitz's excellent TeXblog
A cool trick to turn + - = into alignment marks (e.g. for systems of linear equations)
http://tex.stackexchange.com/questions/6965/multicol-layout-for-systems-of-linear-equations
Cool stuff with figures
http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions
MATLAB code
Get the mcode package, which configures the listings package use with MATLAB. The demo is pretty self-explanatory, and the package works great!
Miscellaneous:
Accent marks:
http://en.wikibooks.org/wiki/LaTeX/Accents
Found this while researching this post and learned a bunch of new things:
http://www.math.uiuc.edu/~hildebr/tex/basics.html
For example, use \eqref to put parentheses around the equation number.
To reduce vertical spacing around section headings: \usepackage[compact]{titlesec}
Cursive lowercase l, as in l2: \ell
Friday, October 7, 2011
LaTeX: getting back in the saddle
After spending more than a year away from LaTeX, I have forgotten so much. Here are the things I've had to look up so far:
Setting up LaTeX
I'm using a Mac now and TeXShop. Fortunately it comes with a template, which I've modified slightly (to use the "article" document class). I also installed cocoAspell, which is a dictionary that will filter out the LaTeX keywords. After installation, you have to go to its section in System Preferences to enable the dictionaries and turn on the LaTeX filter. You could go to either System Preferences -> Language & Text or TexShop's Edit->Show Spelling and Grammar (or both) to set it to use the Aspell dictionary.
LaTeX commands
To change the section and subsection numbering style:
\def\thesection {\arabic{section}.}
\def\thesubsection {(\thesection\alph{subsection})}
Set of all reals:
\usepackage{amssymb}
\mathbb{R}
Indicator function:
\usepackage{bbm}
\mathbbm{1}
Lots of symbols:
http://www.artofproblemsolving.com/Wiki/index.php/LaTeX:Symbols
Aligned equations:
\usepackage{amsmath}
\begin{align*}
g^{-1}(\xi) &= \{x \in \mathbb{R}: g(x) = \xi\} \\
h^{-1}(\psi) &= \{y \in \mathbb{R}: h(y) = \psi\}
\end{align*}
If you're trying to align a single equation in multiple places. The parameter is # of columns, which is (# of & signs + 1)/2. Every other & is for alignment, the other ones specify where to add the whitespace.
\begin{alignat*}{2}
f &= ax + b && \ge 0 \\
h &= cx && = 0
\end{alignat*}
Defining a piecewise function, with the big curly bracket:
f_{Z|X}(z,x) = f_{Y}(z-x) = \begin{cases}
\frac{\mu^{z-x}}{(z-x)!} e^{-\mu} & z-x \ge 0 \\
0 & z-x < 0
\end{cases}
Keeping fractions big:
\frac{\displaystyle ...}{\displaystyle ...}
Particular spacing:
\int x\,dt
i.e.\ in other words
Command shortcuts:
\newcommand{\norm}[1]{\lVert#1\rVert}
\newcommand{\reals}{\ensuremath{\mathbb{R}}}
\def \ba#1\ea {\begin{align*}#1\end{align*}}
Tables:
http://en.wikibooks.org/wiki/LaTeX/Tables
Keeping functions together:
\relpenalty and \binoppenalty
http://www.guyrutenberg.com/2006/12/10/prevent-line-breaking-inline-formula-in-texlatex/
Setting up LaTeX
I'm using a Mac now and TeXShop. Fortunately it comes with a template, which I've modified slightly (to use the "article" document class). I also installed cocoAspell, which is a dictionary that will filter out the LaTeX keywords. After installation, you have to go to its section in System Preferences to enable the dictionaries and turn on the LaTeX filter. You could go to either System Preferences -> Language & Text or TexShop's Edit->Show Spelling and Grammar (or both) to set it to use the Aspell dictionary.
LaTeX commands
To change the section and subsection numbering style:
\def\thesection {\arabic{section}.}
\def\thesubsection {(\thesection\alph{subsection})}
Set of all reals:
\usepackage{amssymb}
\mathbb{R}
Indicator function:
\usepackage{bbm}
\mathbbm{1}
Lots of symbols:
http://www.artofproblemsolving.com/Wiki/index.php/LaTeX:Symbols
Aligned equations:
\usepackage{amsmath}
\begin{align*}
g^{-1}(\xi) &= \{x \in \mathbb{R}: g(x) = \xi\} \\
h^{-1}(\psi) &= \{y \in \mathbb{R}: h(y) = \psi\}
\end{align*}
If you're trying to align a single equation in multiple places. The parameter is # of columns, which is (# of & signs + 1)/2. Every other & is for alignment, the other ones specify where to add the whitespace.
\begin{alignat*}{2}
f &= ax + b && \ge 0 \\
h &= cx && = 0
\end{alignat*}
Defining a piecewise function, with the big curly bracket:
f_{Z|X}(z,x) = f_{Y}(z-x) = \begin{cases}
\frac{\mu^{z-x}}{(z-x)!} e^{-\mu} & z-x \ge 0 \\
0 & z-x < 0
\end{cases}
Keeping fractions big:
\frac{\displaystyle ...}{\displaystyle ...}
Particular spacing:
\int x\,dt
i.e.\ in other words
Command shortcuts:
\newcommand{\norm}[1]{\lVert#1\rVert}
\newcommand{\reals}{\ensuremath{\mathbb{R}}}
\def \ba#1\ea {\begin{align*}#1\end{align*}}
Tables:
http://en.wikibooks.org/wiki/LaTeX/Tables
Keeping functions together:
\relpenalty and \binoppenalty
http://www.guyrutenberg.com/2006/12/10/prevent-line-breaking-inline-formula-in-texlatex/
Tuesday, March 2, 2010
LaTeX things I keep forgetting
Itemize and enumerate spacing
To change the spacing of an itemize environment (or of anything, really, it's just most annoying with itemize):
\setlength{\itemsep}{2pt}
\setlength{\parskip}{0pt}
If you're going to do a lot, then you can define a new environment
\newenvironment{name}
{
\begin{enumerate}
\setlength ...
}
{
\end{enumerate}
}
Graphics
To crop:
[trim=95 25 95 15,clip]
It's left, bottom, right, top
To define a bounding box:
[bb=0 0 719 570]
It's x,y,width,height
Header
\documentclass[12pt,letterpaper]{article}
%\parindent0em
\usepackage{graphicx}
%\usepackage{subfigure}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{float}
\usepackage{lscape}
%\usepackage{mcode}
\addtolength{\oddsidemargin}{-.75in}
\addtolength{\evensidemargin}{-.75in}
\addtolength{\textwidth}{1.5in}
\addtolength{\topmargin}{-.25in}
\addtolength{\textheight}{1.25in}
Note that the length adjustments are based on my LaTeX=>ps always outputting in A4 paper rather than letter...
Hmm...had an issue this time with LaTeX=>ps turning my .jpg into black & white...odd...
But the rest of these tips should work!
To change the spacing of an itemize environment (or of anything, really, it's just most annoying with itemize):
\setlength{\itemsep}{2pt}
\setlength{\parskip}{0pt}
If you're going to do a lot, then you can define a new environment
\newenvironment{name}
{
\begin{enumerate}
\setlength ...
}
{
\end{enumerate}
}
Graphics
To crop:
[trim=95 25 95 15,clip]
It's left, bottom, right, top
To define a bounding box:
[bb=0 0 719 570]
It's x,y,width,height
Header
\documentclass[12pt,letterpaper]{article}
%\parindent0em
\usepackage{graphicx}
%\usepackage{subfigure}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{float}
\usepackage{lscape}
%\usepackage{mcode}
\addtolength{\oddsidemargin}{-.75in}
\addtolength{\evensidemargin}{-.75in}
\addtolength{\textwidth}{1.5in}
\addtolength{\topmargin}{-.25in}
\addtolength{\textheight}{1.25in}
Note that the length adjustments are based on my LaTeX=>ps always outputting in A4 paper rather than letter...
Hmm...had an issue this time with LaTeX=>ps turning my .jpg into black & white...odd...
But the rest of these tips should work!
Subscribe to:
Posts (Atom)