Does anyone know how I could replicate this exam question in Latex? It doesn't have to be exact, just something close to this format. Any help is greatly appreciated!
-
1(not answer but) if you just want output that looks like LaTeX output, switch to Latin Modern font. Alternatively use pandoc to try to convert (presumably) Word file into LaTeX – user202729 May 13 '22 at 13:36
-
1What have you tried? This is not normally a "do it for me" site but more "I have tried but it didn't work as I had hoped". – Peter Wilson May 13 '22 at 17:02
-
Maybe https://tex.stackexchange.com/q/43610/263192 for the curve – May 13 '22 at 17:06
-
Off topic, but I am amazed that statics classes require students to memorize something as obscure as the cumulative probabilities associated with 1, 2 and 3 standard deviations. Thank goodness for calculators with normalcdf. – John Kormylo May 14 '22 at 02:42
2 Answers
You might want to look into the pgfplots package for the curve.
I don't actually know that much about the package or using it; I'm neither a mathematician nor a math teacher nor a skilled pgf/tikz user. I just saw your post and thought that would be fun to try. Here's my amateurish attempt in case it's of any use to you.
Someone who knows it better could probably figure out how to do the correct placement for the dashed lines using a \foreach, but oh well. And the other parts of my attempt are kind of hackish too. Probably an easier way.
Pieces of this blatantly stolen from this answer on a related question and from this different question.
\documentclass{article}
\usepackage[margin=1in]{geometry}
% for the curve figure
\usepackage{pgfplots}
\usetikzlibrary{positioning,calc}
% for the table and the problem numbers
\usepackage{multirow,array}
\usepackage{enumitem}
% needed to plot the curve
\pgfmathdeclarefunction{gauss}{3}{%
\pgfmathparse{1/(#3sqrt(2pi))exp(-((#1-#2)^2)/(2#3^2))}%
}
% a counter to use for the problem numbers
% I start at 31 just to match your sample
\newcounter{mycounter}
\setcounter{mycounter}{31}
\begin{document}
\sffamily% sans serif font; not necessary
\raggedright% don't just full justification, also not necessary
\noindent\begin{tabular}{% begin the table
|p{0.5\textwidth}|% first column is that width with vertical bars
>{\refstepcounter{mycounter}% before the second column we up the counter
\begin{enumerate}[nolistsep,leftmargin=1.5em,% then start a list
label=\textbf{\arabic*.},start=\value{mycounter}%
]\item}% then insert an item for the list
p{0.4\textwidth}% second column is this width
<{\end{enumerate}}% end the list at end of column
@{\qquad}|} % put some space on right of right column
\hline % horizontal line
\multicolumn{2}{|l|}{% first cell takes up two columns
\vphantom{\rule{1pt}{10pt}}\textbf{% add a little padding to top
Label the normal distribution curve, then
answer the questions that follow.}} \ \hline
\multirow{3}{8cm}{% this is the big cell
\smallskip\centering % some space at top, make centered
The ages of the 32 recruits in police academy are normally
distributed with a mean of 27 with a standard deviation of 2.
\smallskip % a little space
\begin{tikzpicture}
\begin{axis}[
domain=21.5:32.5,% x value range
range=0:0.20,% y value range
height=5cm,
width=10cm,
hide x axis,% no axes
hide y axis
]%
% the curve itself
\addplot [very thick] {gauss(x,27,2)};
% line at bottom
\draw [thick] (axis cs:21.5,0) -- (axis cs:32.5,0);
% dashed lines up to curve; I'm sure this can be done a better way
\pgfmathsetmacro\valueMid{gauss(27,27,2)}
\draw [thick, dashed] (axis cs:27,0) -- (axis cs:27,\valueMid);
\pgfmathsetmacro\valueLI{gauss(25.8,27,2)}
\draw [thick, dashed] (axis cs:25.8,0) -- (axis cs:25.8,\valueLI);
\pgfmathsetmacro\valueLM{gauss(24.6,27,2)}
\draw [thick, dashed] (axis cs:24.6,0) -- (axis cs:24.6,\valueLM);
\pgfmathsetmacro\valueLO{gauss(23.4,27,2)}
\draw [thick, dashed] (axis cs:23.4,0) -- (axis cs:23.4,\valueLO);
\pgfmathsetmacro\valueRI{gauss(28.2,27,2)}
\draw [thick, dashed] (axis cs:28.2,0) -- (axis cs:28.2,\valueRI);
\pgfmathsetmacro\valueRM{gauss(29.4,27,2)}
\draw [thick, dashed] (axis cs:29.4,0) -- (axis cs:29.4,\valueRM);
\pgfmathsetmacro\valueRO{gauss(30.6,27,2)}
\draw [thick, dashed] (axis cs:30.6,0) -- (axis cs:30.6,\valueRO);
\end{axis}
\end{tikzpicture}} &
What percent of the recruits are between ages 23 and 27?
\bigskip % put space underneath questions
\\cline{2-2} % draw horizontal line only in second column
&
What is the probability that a recruit is at least 31 years old?
\bigskip
\ \cline{2-2}
&
Approximately how many recruits are at most 29 years old?
\bigskip
\ \hline
\end{tabular}
\end{document}
- 41,473
-
Thank you so much! Much appreciated! Slowly learning more and more about LaTeX. :) Thanks to everyone else who commented as well. There were some good suggestions here and I learned a lot! – Math Teacher needs help May 16 '22 at 12:16
Welcome to tex.stackexchange! I present here a couple of options:
\begin{myquestion}...\quess...\end{myquestion}
and
\begin{myquestionalt}...\quess...\end{myquestionalt}
The first uses TikZ while the second uses a tabular. In both cases, the material in the figure frame (on the left) is pretty much up to you -- you can put anything in there so long as it fits. Anything after \quess (up to \end{...} is an enumerated list, each line beginning with \item. I've included samples in the code.
My main concern was to facilitate entering the questions which is reasonably straightforward. The code is commented, but if there are any problems, adjustments are always possible...
Update
I've add an option to the environments to alter the width of the questions.
\documentclass{article}
\usepackage[]{geometry}
\usepackage{xcolor}
\usepackage{fontspec}
\usepackage{xparse}
\usepackage{tikz}%% For myquestion
\usepackage{enumitem}
\usepackage{keyval}
\usetikzlibrary{calc,shapes.multipart,positioning,trees,snakes}%% For myquestion
%% Store material for the left and right frames:
\newsavebox\figbox
\newsavebox\quebox
\newcounter{quenum}
\newlength{\qsep}
\newlength{\qwidth}
\setlength{\qsep}{0.25in}%% <<< Set as default spacing between questions>>>
\setlength{\qwidth}{4in}%% <<<Set to the desired defaultzz width>>>
%% |=====8><-----| %%
\makeatletter
\define@key{ques}{qsep}{\setlength{\qsep}{#1}}
\define@key{ques}{qwidth}{\setlength{\qwidth}{#1}}
\makeatother
%% |=====8><-----| %% Uses TikZ and shapes.multipart
\NewDocumentEnvironment{myquestion}{O{}m}{%
\setkeys{ques}{#1}
\stepcounter{quenum}
\begin{lrbox}{\figbox}
\begin{minipage}[t]{\dimexpr0.5\qwidth-12pt\relax}%% to fit \qwidth
}{%
\end{enumerate}
\vspace{\qsep}
\end{minipage}
\end{lrbox}
\noindent
\tikz{%
\node[rectangle split,rectangle split parts=2,rectangle split part align=left,draw] (Q) {%
\nodepart{one}\parbox{\dimexpr\qwidth-12pt\relax}{\bfseries#2}
\nodepart{two}\usebox{\figbox}\quad{\usebox{\quebox}}
};%
\draw (Q.one split) -- (Q.south);
}
}
%% |=====8><-----| %% Uses tabular
\NewDocumentEnvironment{myquestionalt}{O{}m}{%
\setkeys{ques}{#1}
\stepcounter{quenum}
\begin{lrbox}{\figbox}
\begin{minipage}[t]{\dimexpr0.5\qwidth-18pt\relax}%% to fit \qwidth
}{%
\end{enumerate}
\vspace{\qsep}
\end{minipage}
\end{lrbox}
\noindent
\begin{tabular}{|l|l|}
\hline
\multicolumn{2}{|l|}{\textbf{#2}}\\hline
\usebox{\figbox}&\usebox{\quebox}\\hline
\end{tabular}
}
\NewDocumentCommand{\quess}{}{% use \item for each question in the right-hand frame
\end{minipage}
\end{lrbox}
%% https://tex.stackexchange.com/questions/21596/resuming-a-list-started-within-a-minipage
\begin{lrbox}{\quebox}
\begin{minipage}[t]{\dimexpr0.5\qwidth-12pt\relax}%% to fit \qwidth
\ifnum\thequenum=1
\begin{enumerate}[nosep,parsep=\qsep,label=\textbf{\arabic.},leftmargin=,series=mylist]
\else
\begin{enumerate}[label=\textbf{\arabic.},resume=mylist,leftmargin=*]
\fi
}
%% |=====8><-----| %%
% Use:
% \begin{myquestion}{<The title or question>}%% or: \begin{myquestionalt}{<The title or question>}
% contents of the left side for figures, etc
% \quess
% Enumerate questions (use \item)
% \end{myquestion}%% or \end{myquestionalt}
% or, showing optional argument:
% \begin{myquestion}[qsep=0.25in]{<The title or question>} or
% \begin{myquestion}[qsep=0.25in]{<The title or question>}%%
% contents of the left side
% \quess
% Enumerate questions (use \item)
% \end{myquestion}%% or \end{myquestionalt}
\begin{document}
\begin{myquestion}[qwidth=4.5in]{This is a test using Ti\emph{k}Z}%% Uses default qsep
\centering
A Ti\emph{k}z figure on the left
%% https://texample.net/tikz/examples/title-graphics/
\tikzstyle{level 1}=[sibling angle=120]
\tikzstyle{level 2}=[sibling angle=60]
\tikzstyle{level 3}=[sibling angle=30]
\tikzstyle{every node}=[fill]
\tikzstyle{edge from parent}=[snake=expanding waves,segment length=1mm,
segment angle=10,draw]
\scalebox{0.4}{%
\begin{tikzpicture}[grow cyclic,shape=circle,very thick,level distance=13mm,cap=round]
\node {} child [color=\A] foreach \A in {red,green,blue}
{ node {} child [color=\A!50!\B] foreach \B in {red,green,blue}
{ node {} child [color=\A!50!\B!50!\C] foreach \C in {black,gray,white}
{ node {} }
}
};
\end{tikzpicture}
\vspace{0.1in}
}
\quess
\item A first question that might actually be quite lengthy
\item A second question
\item A third question
\end{myquestion}
\begin{myquestion}[qsep=0.5in]{This is another test}%%
A figure on the left
\includegraphics[width=0.5\linewidth]{example-image-a}
\quess
\item A fourth question
\item A fifth question
\item A sixth question
\end{myquestion}
%% |=====8><-----| %%
\setcounter{quenum}{0}%% <<<Use this to start a new series of questions>>>
\begin{myquestionalt}{This is a test using a tabular}
\centering
A Ti\emph{k}z figure on the left
%% https://texample.net/tikz/examples/title-graphics/
\tikzstyle{level 1}=[sibling angle=120]
\tikzstyle{level 2}=[sibling angle=60]
\tikzstyle{level 3}=[sibling angle=30]
\tikzstyle{every node}=[fill]
\tikzstyle{edge from parent}=[snake=expanding waves,segment length=1mm,
segment angle=10,draw]
\scalebox{0.4}{%
\begin{tikzpicture}[grow cyclic,shape=circle,very thick,level distance=13mm,cap=round]
\node {} child [color=\A] foreach \A in {red,green,blue}
{ node {} child [color=\A!50!\B] foreach \B in {red,green,blue}
{ node {} child [color=\A!50!\B!50!\C] foreach \C in {black,gray,white}
{ node {} }
}
};
\end{tikzpicture}\par
}
\vspace{3pt}
\quess
\item A first question
\item A second question
\item A third question
\end{myquestionalt}
\begin{myquestionalt}[qwidth=3.75in,qsep=0.15in]{This is another test}
A figure on the left
\includegraphics[width=0.5\linewidth]{example-image-b}
\quess
\item A fourth question
\item A fifth question
\item A sixth question
\end{myquestionalt}
\end{document}
- 8,586


