Allen J. Hall

Materials Science & Engineering, Productivity, and Life

LaTeX Tip: NewCommand

For those friends of mine currently attempting to work in LaTeX to code Materials Science and Engineering related tidbits…

Here’s a quick tip. Tired of typing all those crazy math commands for your material’s name? Simply use a new command. Here’s are a couple examples…

%Simpler way of writing CUINSE2:
\newcommand{\cis}{CuInSe$_{2}$}

%Simpler way of writing CUINGASE2:
 \newcommand{\cigs}{CuIn$_{(1-x)}$Ga$_{x}$Se$_{2}$}

%Simpler way of writing CUGASE2:
\newcommand{\cgs}{CuGaSe$_{2}$}

To see how this looks in compiled LaTeX output and another example, click “More”…

Add that to the top of your latex doc (below the document class stuff of course), and then when you need to type the name of CIS for instance, simply type: “\cis{}” Much faster for those underscores or more complicated material names.

The output will look like this (the way I currently have math mode enabled) for my \cigs{} command similar to the above:

LaTeX-CIGS

For those Miller Bravais directions, there are a few ways to do it:

% form of lattice planes
\newcommand{\lattplaneform}[1]{\ensuremath{\{#1\}}}

The above will take anything you put after the new command like so: “\lattplaneform{0 0 1}” and turn it into the planeform: {0 0 1}. Now, that’s fine, but you can gain a bit more control if you do something like this:

% New Command for Lattice Vectors
\newcommand{\lattplaneform}[3]{\ensuremath{\{#1\:#2\:#3\}}}

Notice that the “\:” is a finer control over spacing in math-mode (see lshort.pdf for more on math-mode spacing). Now, we call the command like so: \lattplaneform{1}{1}{3} which will output: {1 1 3} with finer spacing. We can also add overlines for negative numbers: \lattplaneform{1}{1}{\overline{3}}.

Output will look like so for my \complexlattplane{} command.  I added the $_{Tetragonal}$ after the newcommand:

LaTeX-Vector

So, newcommand is your friend!

Post a Comment

Your email is never shared. Required fields are marked *

*
*

A Quick Introduction...

I'm a graduate student (PhD Candidate) at the University of Illinois at Urbana-Champaign.

I've studied and researched in two fields of Materials Science and Engineering (Polymers and Semiconductors). My interests are as diverse as my musical tastes and I usually have my hand in some crazy project during my free time.

I'm available for consulting and have access to a world-renown materials research user-facility supported by the D.O.E. If you would like to know more, please contact me.

Popular Tags

Amazon Associate Link Apple Support AppStore Bug CIGS CIS CLI Conferences Cross Platform Data Mining data visualization dual-driver headphones failure Friend Geek Tool Great Scientists HAM Radio Hardware Tips How To Humanitarian IEM IM In-Ear Monitors iPod Touch LaTeX Linux Mac OsX Materials Science and Engineering Matlab Obituary Open Source problem Productivity reciprocal space return Silent Key Software Software Review Support This Blog Thesis Writing Tip UIUC VOIP Windows xrd

Support This Blog

You can support this blog by shopping on Amazon through my Affiliate Store.