Saturday, October 11, 2014

LaTeX: Lists

Lists

In my last tutorial, I stated that I would go over lists in LaTeX. Well, here is how to create lists in LaTeX!

Bullet Points

Making bullet points in LaTeX is very simple. Within the \begin{document} and \end{document}, put \begin{itemize}. Texmaker should auto complete that to add \end{itemize} as well. Now, in between itemize put in \item and add whatever you with to put in bullet points. For example, 

Variable Types
\begin{itemize}
\item float
\item boolean
\item char
\item double
\end{itemize}

This will produce:


 This is fine if we want only one level, but what if we want sub-points? This is done by adding another {itemize}. If we were to categorize variable types by whether they deal with numbers, letters, or other we could do this:

 
Variable Types
\begin{itemize}
    \item Numbers
    \begin{itemize}
        \item byte
        \item integer
        \item decimals
        \begin{itemize}
            \item float
            \item double       
        \end{itemize}
    \end{itemize}
    \item Letters
    \begin{itemize}
        \item char
        \item string
    \end{itemize}
    \item Truth values
    \begin{itemize}
        \item boolean
    \end{itemize}
\end{itemize}
\end{document}

This code will produce the result:

 
 Let's say, however, that you want to make numbered lists. 

Numbered Lists

  

Creating numbered lists is similar to creating lists with bullet points in the sense that they both use \begin and \end. However, while lists with bullet points use {itemize}, numbered lists use {enumerate} 
Let's say, for the sake of example, I wanted to create a list of programming languages I am proficient in on a resume. I could do this:

 Programming Languages
\begin{enumerate}
    \item Python
    \item Ruby
    \item C++
    \item Objective-C
    \item Java
\end{enumerate} 


Giving me the output:



Lastly, we can combine both numbers and bullet points by inserting the \begin{enumerate} within a \begin{itemize}

Going back to the example I had before, assuming that I wanted to separate these programming languages by bullet points I could do:

\begin{itemize}

\item Scripting Languages
    \begin{enumerate}      
    \item Python
    \item Ruby
    \end{enumerate}
\item Compiled Languages
    \begin{enumerate}
    \item C++
    \item Objective-C
    \item Java
    \end{enumerate} 

\end{itemize}


This will end up giving us the output:



That's the end of today's lesson. In the next lesson, I will go over how to set up a TeX document for a lab report. 

No comments:

Post a Comment