Graphics, Figures & TablesCreating a table for multiple choice exams

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
kapowza
Posts: 19
Joined: Fri Jan 30, 2009 3:32 pm

Creating a table for multiple choice exams

Post by kapowza »

First of all, I'm very new to latex so this is probably a very simple question.

I'd like to make multiple choice exams that look like this: http://www.math.uwo.ca/~milnes/Math1225 ... arv103.pdf

I'm having trouble creating a table with a black border. Or even a table, as in problem 13, where there's no border around the 2nd row, 3rd column entry.

Can anyone offer some advice? Thanks.

Recommended reading 2024:

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

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

marco_d
Posts: 57
Joined: Tue Jan 20, 2009 7:49 pm

Creating a table for multiple choice exams

Post by marco_d »

Hello,

Code: Select all

\documentclass[10pt]{article}

\usepackage{array,tabularx}
\usepackage{amsmath}
\newcommand{\myitem}[6]{#1\par\renewcommand{\arraystretch}{2}\setlength{\arrayrulewidth}{2pt}
        \begin{tabularx}{\linewidth}{|X|X|X|X|X|}\hline
          A:~$#2$ & B: $#3$ & C: $#4$ & D: $#5$ & E: $#6$  \\[1ex]\hline
        \end{tabularx}}
\begin{document}
 \begin{enumerate}
 \item Simplify $\dfrac{\log_34+\log_38}{\log_38}$\par
        \renewcommand{\arraystretch}{2}
        \setlength{\arrayrulewidth}{2pt}
        \begin{tabularx}{\linewidth}{|X|X|X|X|X|}\hline
          A: $\log_34$ & B: $\log_35$ & C: $\dfrac{5}{3}$ & D: $3$ & E: $4$  \\[1ex]\hline
        \end{tabularx}
 \item \myitem{If $f(x)=\log_5x$, find $f'(x)$} {\dfrac{1}{x}} {\dfrac{5}{x}} {\dfrac{1}{5x}} {\dfrac{1}{x\ln 5}} {\dfrac{\ln5}{x}}
\end{enumerate}

\end{document}
regards
Marco
i am German. I can not use difficult words. :-)
kapowza
Posts: 19
Joined: Fri Jan 30, 2009 3:32 pm

Re: Basic Table Question

Post by kapowza »

Thank you! That worked perfectly! Now, I'm just wondering if there's a way to make tables as in questions 10, 13, 23, etc, where one of the cells has no border.
marco_d
Posts: 57
Joined: Tue Jan 20, 2009 7:49 pm

Creating a table for multiple choice exams

Post by marco_d »

Hello

in this case you need the commands multicolumn and cline.

Code: Select all

    \documentclass[10pt]{article}
    \usepackage{geometry}
    \geometry{left=2cm,right=2cm}

    \usepackage{array,tabularx}
    \usepackage{amsmath}
    \newcommand{\myitemone}[6]{#1\par\renewcommand{\arraystretch}{2}\setlength{\arrayrulewidth}{2pt}
            \begin{tabularx}{\linewidth}{|X|X|X|X|X|}\hline
              A:~$#2$ & B: $#3$ & C: $#4$ & D: $#5$ & E: $#6$  \\[1ex]\hline
            \end{tabularx}}
    \newcommand{\myitemtwo}[6]{#1\par\renewcommand{\arraystretch}{2}\setlength{\arrayrulewidth}{2pt}
            \begin{tabularx}{\linewidth}{|X|X|X|X|X|}\hline
              A:~$#2$ & B: $#3$ & C: $#4$              \\[1ex]\hline
              D: $#5$ & E: $#6$ & \multicolumn{1}{c}{} \\[1ex]\cline{1-2}
            \end{tabularx}}
    \begin{document}
    \begin{enumerate}
    \item Simplify $\dfrac{\log_34+\log_38}{\log_38}$\par
            \renewcommand{\arraystretch}{2}
            \setlength{\arrayrulewidth}{2pt}
            \begin{tabularx}{\linewidth}{|X|X|X|X|X|}\hline
              A: $\log_34$ & B: $\log_35$ & C: $\dfrac{5}{3}$ & D: $3$ & E: $4$  \\[1ex]\hline
            \end{tabularx}
    \item \myitemone{If $f(x)=\log_5x$, find $f'(x)$} {\dfrac{1}{x}} {\dfrac{5}{x}} {\dfrac{1}{5x}} {\dfrac{1}{x\ln 5}} {\dfrac{\ln5}{x}}
    \item \ldots
    \item Find $\int\dfrac{2x+1}{2x}\mathrm dx$
           \par
            \renewcommand{\arraystretch}{2}
            \setlength{\arrayrulewidth}{2pt}
            \begin{tabularx}{\linewidth}{|X|X|X|}\hline
              A: $\dfrac{x^2+x}{x^2}+C$ & B: $\dfrac{(2x+1)^2}{2}\ln|2x|+c$ & C: $\ln|2x+1|-\ln|2x|+C$\\[1ex]\hline
              D: $x+\ln|2x|+C$ & E: $x+\dfrac{1}{2}\ln|x|+C$ &\multicolumn{1}{c}{} \\[1ex]\cline{1-2}
            \end{tabularx}
    \item \myitemtwo {$\int(\ln(x)^2\mathrm dx=$} {\dfrac{2\ln x}{x}+C} {\dfrac{\ln(x)^3}{3}+X} {(x\ln-x)^2+C}% 
                     {x\ln(x)^2-2\int\ln x\mathrm dx} {x^2\ln x-\dfrac{1}{2}\int \ln x\mathrm dx}
    \end{enumerate}

    \end{document}
regards
Marco

EDIT: I changed the code
i am German. I can not use difficult words. :-)
Post Reply