LaTeX

From the Linux and Unix Users Group at Virginia Teck Wiki
(Redirected from LaTex)
Jump to: navigation, search

LaTeX is a markup language and typesetting system for producing high-quality documents. The X symbol is supposed to represent the Greek character chi, making the proper pronunciation lah-tech or lay-tech.

Sample LaTeX Stub

\documentclass{article}

\usepackage{fullpage}

\author{Hokie Hackman}
\title{My Favorite Class\\Homework 1}

\begin{document}

\maketitle

\end{document}

Formatting Assignments

LaTeX is probably the best tool available for typesetting documents involving math. Below are some pointers on formatting school assignments.

Smaller Margins

The article class defaults to rather large margins. An easy way to make the margins smaller is to include the fullpage package.

\documentclass{article}
\usepackage{fullpage}
\begin{document}
Hello, and welcome to a paragraph that begins much closer than usual to the left side of the page.
\end{document}

Upper Right-Hand Corner

For some assignments you may be required to put your name, ID number, the date, or other elements at the top right-hand corner of the first page. The flushright environment can accomplish this.

\documentclass{article}
\begin{document}
\begin{flushright}
Hokie Hackman\\
905001337\\
My Favorite Class\\
\today
\end{flushright}
\end{document}

Nonsequential Enumerated Items

The enumerate environment is useful for numbered lists, and while the enumerate offers a quick way to change the counter for a whole list of sequential items, no extra package is necessary to number \items individually. Passing an argument to each \item is probably the easiest way to number homework problems that aren't sequential in LaTeX.

\documentclass{article}
\begin{document}
\begin{enumerate}
\item[4.10] What is $1+1$?

\[ 1+1=2 \]

\item[4.12] What are the first two prime numbers?

The first two prime numbers are two and three.

\item[4.25] In what year was the Free Software Foundation formed?

The FSF was founded in 1985.

\end{enumerate}
\end{document}

Karnaugh Maps

There are a couple k-map packages available. We should document which one is better, and what it's packaged with (science?).

Spell Checking

The following command can be used to spell check (La)TeX documents.

aspell -c -t document.tex

Error Messages

  • The line with the bang (!) on it is the error message.
  • The number after l. is the line number where the error occurred.

Extra alignment tab has been changed to \cr

! Extra alignment tab has been changed to \cr.
<template> \egroup \endtemplate

This can happen when a line of your eqnarray is missing its endline mark: \\.

Missing $ inserted

! Missing $ inserted.
<inserted text>

This can happen when you leave out a closing inline equation mark: $.

Example LaTeX documents

Echarlie's Chem 1045 Lab report

% A Lab report of the style from the 2015/2016 lab manual, prepared by echarlie
% uses bibtex, and a number of features documented in the LaTeX wikibook
% Notice that copying this document Verbatim will result in Submission to Honour Court
% However, author releases it under CC-BY-SA as is standard for this wiki
% Contains all headers; ones not used in this report are commented out

\documentclass[12pt]{article}
\usepackage{enumerate}
\usepackage[margin=1in]{geometry}
\usepackage{natbib}
\usepackage{booktabs}
\usepackage{listings}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage{caption}
\usepackage{float}
\usepackage{natmove}
%\usepackage{mhchem}  %Useful for Chem diagrams and eqns, if you need it
\bibliographystyle{achemso}
\setcitestyle{super,open={},close={}}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{graphicx}

\newcommand\labtitle{
Applying Lab Learning and\\ Techniqes to Real-Life Applications:\\ Quantification
of Cranberry\\in Cranberry-Apple Juice
}

\newenvironment{titlecrap}


\begin{document}
\begin{titlecrap}
{{	\centering
	{\large \bfseries \labtitle \par}
	\vspace{8 pt}
	{\normalsize John V. Doe and Jane K. Dee \par}
	{\normalsize Submitted to: Wadsworth Longbottom \par} %Your TA
	{\normalsize \it CHEM 1045, Experiment 10 \par}
	{\normalsize \it \today \par}	
	\vspace{6 pt}
}
	{\raggedright
	\begin{picture}(6.5, .5)
	\setlength{\unitlength}{1in}
	\put(0, 0){\line(1, 0){6.5}}
	\end{picture}
	\par \vspace{8 pt}
}

	{\raggedleft
		{\normalsize \it Honour Code Signature: \hspace{8pc }} %SIGN YOUR NAME

	}
}
\end{titlecrap}

\begin{abstract} %This isn't a good abstract, but the format is correct: single spaced

	Students determined the percentage cranberry juice in a cranberry-apple juice mixture.
	Spectrophotometry concepts were used to prepare a calibration curve, and from this, and
	knowledge of the absorbtion of apple juice, the concentration of cranberry juice in
	the juice mixture was determined to be about 9.042\%, with all effects of the apple
	juice neglected due to increased complexity.

\end{abstract}

\baselineskip = 24pt
\section{Introduction}

In this lab, students calculated the total percentage of cranberry juice in a cranberry-apple
mixture. Students used concepts of spectrophotometry and dilution to prepare a calibration
curve, against which the absorbtion spectrum of the cranberry-apple juice is compared, following
the Beer-Lambert law. Students
also use knowledge of light to determine whether the apple juice present contributes to the
deep red colour of the cranberry-apple juice.
The spectrophotometric techniques used differ from those used in other labs: this
spectrophotometer determines the absorbance at a range of wavelengths and presents this data
as a graph, making it easy to determine the maximum absorbance and compare those of two different
substances.

\section{Experimental}
	\subsection*{\underline{\normalsize \rm Procedure:}}

	First, 20\% solutions of the cranberry juice and the apple juice are prepared for
	testing: 100 mL of the cranberry dilute is produced, and about 50 mL of the apple
	dilute is prepared. The absorbtion spectra of both are measured with the
	spectrophotometer, recording the absorbance at the wavelenght of highest
	absorption ($\lambda _{\mathrm{max}}$) for cranberry.
	
	A calibration curve is prepared, using dilutions of 4\%, 8\%, 12\%, and 16\%
	cranberry prepared from the 20\%, along with the 20\% sample already prepared.
	The absorbance of each at $\lambda _{\mathrm{max}}$ is used to create a calibration
	curve.

	Finally, measure the absorbance of the cranberry-apple juice at $\lambda _{\mathrm{max}}$
	and determine the concentration of cranberry juice in the cranberry-apple juice mixture.


	\subsection*{\underline{\normalsize \rm Data:}}

	\begin{table}[h] %A table with a caption; good style for presenting data
		\begin{center}
		\begin{tabular}{ c c c }
			\multicolumn{3}{c}{\bf Measured Absorption at 510 nm}\\
			\toprule
			Juice & Concentration (\%) & Absorption\\
			\hline
			Cranberry	& 4	& 0.329\\
			Cranberry	& 8	& 0.557\\
			Cranberry	& 12	& 0.744\\
			Cranberry	& 16	& 1.007\\
			Cranberry	& 20	& 1.400\\
			Apple		& 20	& 0.137\\
			Cran-Apple	& Unknown& 0.604\\
			\bottomrule
		\end{tabular}
		\end{center}
		\caption{Absorption of standard solutions and the unknown sample}
		\label{tab:Conc}
	\end{table}

	\begin{figure}[h] %A graph (PDF generated from SVG in Inkscape; SVG generated by LibreOffice from collected data)
		\begin{center}
		\includegraphics[width=5in]{CalCurve10}
		\end{center}
		\caption{\centering Graph made from Table \ref{tab:Conc} showing straight-line\\
					relation of calibration curve absorbance}
		\label{fig:cal}
	\end{figure}

%        \subsection*{\underline{\normalsize \rm Observations:}}

\vfill\eject %this creates a new page

\section{Results and Discussion}
	\subsection*{\underline{\normalsize \rm Results and Discussion:}}

	The apple juice has one-tenth the absorbance of the cranberry juice at 510 nm, and
	therefore, for this calculation, can be assumed negligible: it increases the complexity
	without being a significant source of error. Based on the colour of the apple
	juice, I am surprised it contributes any significant absorbtion at 510 nm, deep in the
	green spectrum, to anything at all.

	However, since it does contribute some absorbance, this will result in a high
	concentration of cranberry compared to the actual value, since cranberry would then not
	be the only source of colour and absorption at that wavelength.

	The cranberry juice absorbs very little outside of the 510 nm wavelength, resulting in
	its profoundly red colour (if green is absorbed, red -- opposite green on the colour
	wheel -- is not absorbed). Apple juice has a yellow hue, indicating most of the absorption
	happens in the purple spectrum. This is why the apple juice has a low affect on the
	absorbtion of the cranberry-apple juice.
	
	\subsection*{\underline{\normalsize \rm Sample Calculations:}}

	Concentration of the unknown can be directly calculated using known absorbances and the
	calibration curve (figure \ref{fig:cal}) slope:
	$$f(x) = \mathrm{absorbance} = 0.604$$
	$$x = \mathrm{concentration}$$
	$$f(x) = 0.0668x $$
	$$\frac{0.604\,abs}{0.0668\,\cfrac{abs}{\%}} = 9.042 \%\,\mathrm{cranberry\,juice}$$
	
	If the absorbance of the apple juice is accounted for, then one-eleventh of the
	absorbance is caused by the apple juice, or:
	$$\frac{10}{11} * 9.042 \%\,\mathrm{cranberry+apple\,juice} = 8.22\%$$
	While this is a non-negligible difference, this is also based on
	assumptions of accuracy for
	the value of absorbance of apple juice at $\lambda _{\mathrm{max}}$, basically
	a two-point calibration curve, and the assumption that the apple juice is at the
	same concentration, which is not a valid assumption.

	\subsection*{\underline{\normalsize \rm Experimental Uncertainty:}}

	The largest source of error in results is the compexity of calculating the exact
	concentration of cranberry, by accounting for apple juice and other additives in the
	cranberry-apple juice.


\section{Conclusions}

This lab exposed students to the Beer-Lambert law, and honed skills of using spectrophotometry,
calibration curves, dilution concepts, and general laboratory technique. The final concentration
of cranberry in the cranberry-apple juice was determined to be about 9.042\%, neglecting all
effects of the apple juice on absorbtion spectrum.

\bibliography{HumanUnreadable,savedrecs} %this part is autogenerated from .bib files named there, in the ASC format
                                         %Should be named references; Should be numbered like a section (but that is hard)


\section*{Supporting Information} %Not numbered
        \subsection*{\underline{\normalsize \rm Answers to Post-Laboratory Questions:}}

\begin{enumerate}
	\item The carrot juice in this cranberry-apple juice has pigmentation which absorbs a
		broader spectrum than cranberry juice alone does. This juice will be darkest if
		the carrot juice absorbed in the red spectrum, however, presuming it absorbs in
		the blue spectrum (opposite orange on the colour wheel), the juice would absorb
		a large block in what are traditionally described as ``cool colours'', thus
		the juice will appear as a very dark red-orange.

	\item In this article, Polish researchers Wiczkowski et al. studied the effect of
		fermentation of cabbage on human antioxidant capacities. Their research focused
		on the effects of fermentation on the presence of anthocyanins, which they then
		concluded is correlated to human antioxidant capacities. It was determined that
		bioavailability of anthocyanin was 10\% higher in fresh cabbage, and consequently
		antioxidant capacities of the humans eating the fresh cabbage was higher than that
		of those consuming the fermented cabbage\cite{cabbage}.
\end{enumerate}

\end{document}