Text FormattingLining up answers

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
tcadena411
Posts: 5
Joined: Sun Aug 09, 2009 12:41 am

Lining up answers

Post by tcadena411 »

Okay, so I am new to LaTeX and I haven't been able to get these equations to line up right. Here is my code:

Code: Select all

\documentclass{article}
\title{Domain I}
\date{}
\setlength{\parindent}{0pt}
\pdfpagewidth 8.5in
\pdfpageheight 11in

\begin{document}
\maketitle

\section{Competency 001}
\label{sec:Competency 001}

\begin{enumerate}

\item Which of the following is an irrational number?

\subitem (a) 5/8

\subitem (b) \sqrt{2} 

\subitem (c) 2.85

\subitem (d) 1/2


\end{enumerate}
\end{document}
Down below is what it looks like after I compile it.

Any help is greatly appreciated. Thanks.
Attachments
Results of program.pdf
(18.2 KiB) Downloaded 292 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Lining up answers

Post by localghost »

You forgot some input for math mode. Check the log file for error messages. The \subitem command is usually for the theindex environment. To get a proper result you should nest several enumerate environments. The enumitem package simplifies customization of such lists.

Code: Select all

\documentclass[letterpaper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{nicefrac}

\setlength{\parindent}{0pt}
\author{tcadena411}
\title{Domain I}
\date{}

\begin{document}
  \maketitle

  \section{Competency 001}\label{sec:competency001}
    \begin{enumerate}
      \item Which of the following is an irrational number?
      \begin{enumerate}[label=(\alph*)]
        \item $\nicefrac{5}{8}$
        \item $\sqrt{2}$
        \item 2.85
        \item $\nicefrac{1}{2}$
      \end{enumerate}
    \end{enumerate}
\end{document}

Best regards and welcome to the board
Thorsten
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Lining up answers

Post by frabjous »

That code generates 4 errors for me. The reason is that \sqrt is a math mode command and needs to put in mathmode. Wrapping in $..$ should do the trick:

The following code works just fine for me:

Code: Select all

\documentclass{article}
\title{Domain I}
\author{}
\date{}
\setlength{\parindent}{0pt}
\pdfpagewidth 8.5in
\pdfpageheight 11in

\begin{document}
\maketitle

\section{Competency 001}
\label{sec:Competency 001}

\begin{enumerate}

\item Which of the following is an irrational number?

\subitem (a) 5/8

\subitem (b) $\sqrt{2}$

\subitem (c) 2.85

\subitem (d) 1/2


\end{enumerate}
\end{document}
\subitem seems to be working just fine for me, unlike Thorsten.
tcadena411
Posts: 5
Joined: Sun Aug 09, 2009 12:41 am

Re: Lining up answers

Post by tcadena411 »

Thanks Thorsten and Frabjous. I appreciate the help. I got it working now.
Post Reply