在工作表中嵌入示例和解决方案

在工作表中嵌入示例和解决方案

我如何将示例和解决方案“嵌入”到我的代码中以制作易于使用的工作表和解决方案手册?

背景:我正在为学生创建一本分数练习册,其中许多学生在生活中遇到许多不幸的挑战,因此该练习册必须优步易于使用。这意味着解决方案手册需要看起来确切地就像工作表一样,只是里面有答案。我一直在努力实现这一点,甚至不知道如何制作一个像样的 MWE。

以下是我尝试的 MWE 的链接和我想要的 PDF。还有很大的差距需要弥补!

(如果需要将此线程分解为更小的部分,请告诉我,我会这样做。)

有什么建议么?

我想要的样子,用笔编辑

在此处输入图片描述

我的 LaTeX 代码的 MWE

\documentclass[12pt,letterpaper]{article}

\usepackage{amsmath}
\usepackage{exsheets}
\usepackage{tikz}

% underline/answer space macro
\newlength{\ALT} %Sets name new my length, where ALT = Answer Line Thickness
\setlength{\ALT}{0.5pt} %sets thickness of that line
\newlength{\DLL} % DLL = default line length; that is if I don't otherwise specify the line length, it will be as long as I set it to here.
\setlength{\DLL}{0.8cm}
\newcommand{\AS}[1][\DLL]{\rule{#1}{\ALT}}

\begin{document}

\section{Worksheet Now}
Find the unknown.

\begin{question}
\(3+\AS=4\)
\end{question}

\begin{solution}
\(1\)
\end{solution}

\begin{question}
\(4=\AS-10\)
\end{question}

\begin{solution}
\(14\)
\end{solution}

\noindent
Shade the indicated length starting at zero.
\begin{question}
\(\frac{2}{5}\)

\tikz[xscale=2]
{
 % X axes
 \draw [line width =1pt]
  (0,0)--(3,0)
  (0,.5)--(3,0.5);
 % Vertical tick marks and answer boxes
 \foreach \x in {0,...,15}
  \draw [line width=1pt](\x/5,-0.4)--(\x/5,0.5);
 % Whole Number Labels
 \foreach \x in {0,1,2,3}
  \node[below] at (\x,-0.6) {\x};
}
\end{question}

\begin{solution}
\(\frac{5}{3}\)

\tikz[xscale=2]
{
 % Shaded bar length
 \filldraw[gray] (0,0) rectangle ({2/5},0.5);
 % X axes
 \draw [line width =1pt]
  (0,0)--(3,0)
  (0,.5)--(3,0.5);
 % Vertical tick marks and answer boxes
 \foreach \x in {0,...,15}
  \draw [line width=1pt](\x/5,-0.4)--(\x/5,0.5);
 % Whole Number Labels
 \foreach \x in {0,1,2,3}
  \node[below] at (\x,-0.6) {\x};
}
\end{solution}

\begin{question}
\(\frac{5}{3}\)

\tikz[xscale=1.5]
{
 % X axes
 \draw [line width =1pt]
  (0,0)--(3,0)
  (0,.5)--(3,0.5);
 % Vertical tick marks and answer boxes
 \foreach \x in {0,...,9}
  \draw [line width=1pt](\x/3,-0.4)--(\x/3,0.5);
 % Whole Number Labels
 \foreach \x in {0,1,2,3}
  \node[below] at (\x,-0.6) {\x};
}
\end{question}

\begin{solution}
\(\frac{5}{3}\)
\tikz[xscale=1.5]{
 % Shaded bar length
 \filldraw[gray] (0,0) rectangle ({5/3},0.5);
 % X axes
 \draw [line width =1pt]
  (0,0)--(3,0)
  (0,.5)--(3,0.5);
 % Vertical tick marks and answer boxes
 \foreach \x in {0,...,9}
  \draw [line width=1pt](\x/3,-0.4)--(\x/3,0.5);
 % Whole Number Labels
 \foreach \x in {0,1,2,3}
  \node[below] at (\x,-0.6) {\x};
}
\end{solution}

\pagebreak
\section{Solutions Now}
\printsolutions

\end{document}

答案1

我不会使用exsheets'solution环境,除非你想打印解决方案分别地来自练习。相反,我会使用条件开关。例如exsheets提供

\PrintSolutionsTF{if answers are printed}{if answers are not printed}
\PrintSolutionsT{if answers are printed}
\PrintSolutionsF{if answers are not printed}

可以用它们来定义宏

\newcommand\answer[1]{\PrintSolutionsTF{#1}{\phantom{#1}}}

这将打印参数或参数所需的空间。更多自定义(颜色、带下划线的答案、空格……- 使用包xcolor):

\makeatletter
% a color for answers:
\colorlet{answercolor}{orange}

\newcommand\answer[1]{\PrintSolutionsTF{#1}{\phantom{#1}}}

\newlength\answerspace
\setlength\answerspace{2cm}

\newcommand\answerline[1]{%
  \ifmmode
    \answerline@math{#1}%
  \else
    \answerline@text{#1}%
  \fi
}

\newcommand*\answerline@text[1]{%
  \underline{\makebox[\answerspace][c]{\answer{\color{answercolor}#1}}}%
}
\newcommand\answerline@math[1]{\mathpalette\answer@line@math{#1}}
\newcommand\answer@line@math[2]{\answerline@text{$#1#2$}}
\makeatother

还可以用一个lrbox来定义更大块输入的环境。

因此,完整的示例如下:

\documentclass{article}
\usepackage{exsheets,amsmath,tikz}

\makeatletter
% a color for answers:
\colorlet{answercolor}{orange}

\newcommand\answer[1]{\PrintSolutionsTF{#1}{\phantom{#1}}}

\newlength\answerspace
\setlength\answerspace{2cm}

\newcommand\answerline[1]{%
  \ifmmode
    \answerline@math{#1}%
  \else
    \answerline@text{#1}%
  \fi
}

\newcommand*\answerline@text[1]{%
  \underline{\makebox[\answerspace][c]{\answer{\color{answercolor}#1}}}%
}
\newcommand\answerline@math[1]{\mathpalette\answer@line@math{#1}}
\newcommand\answer@line@math[2]{\answerline@text{$#1#2$}}
\makeatother


% uncomment to get answers printed:
% \SetupExSheets{solution/print=true}

\begin{document}

\section*{Find the unknown.}
\begin{question}
  \( 3 + \answerline{1} = 4 \)
\end{question}
\begin{question}
  \( 4 =  \answerline{14} -10 \)
\end{question}

\section*{Shade the indicated length starting at zero.}
\begin{question}
  \(\frac{2}{5}\)

  \begin{tikzpicture}
    \PrintSolutionsT{ \fill[answercolor] (0,0) rectangle (1,.5) ; }
    \draw[step=5mm] (0,0) grid (7.5,.5) ;
    \foreach \x [evaluate=\x as \xpos using \x*2.5] in {0,...,3}
      { \draw (\xpos,0)--++(0,-.2) node[below] {\x} ; }
  \end{tikzpicture}      
\end{question}

\begin{question}
  \(\frac{5}{3}\)

  \begin{tikzpicture}
    \PrintSolutionsT{ \fill[answercolor] (0,0) rectangle (2.5,.5) ; }
    \draw[step=5mm] (0,0) grid (4.5,.5) ;
    \foreach \x [evaluate=\x as \xpos using \x*1.5] in {0,...,3}
      { \draw (\xpos,0)--++(0,-.2) node[below] {\x} ; }
  \end{tikzpicture}
\end{question}

\end{document}

这给出

在此处输入图片描述

\SetupExSheets{solution/print=true}

在此处输入图片描述

相关内容