Quiero hacer un folleto que contiene muchas preguntas.
Quiero un resultado de esto:
Otra salida es así:
La tercera salida es así:
Calcular 1+2
Calcular 1+2+3
Calcular 1+2+3+4
Calcular 1+2+3+4+5
Calcular 1+2+3+4+5+6
El problema aquí es solo mi ejemplo: tengo miles de preguntas de exámenes de secundaria. ¿Quién puede enseñarme a utilizar solo una salida de archivo TEX de tres tipos de archivos PDF? ¡Muchas gracias!
Respuesta1
Además de lo que dijo Erik, descubrí que para muchas clases quería el texto de todas las preguntas seguido de cada pregunta con espacio para completar. Extendí la clase de examen para hacer esto automáticamente, con solo escribir las preguntas una vez y un par de pasadas del compilador.
%\NeedsTeXFormat{Latex2e}[1996/06/01]
\ProvidesClass{examExt}[2016/11/09 v1.0]
\LoadClassWithOptions{exam}
\RequirePackage{etex}
\global\newwrite\examfile%
\newcommand\insertQuestions[1][plain]{
\begingroup
\IfFileExists{./\jobname.exm}{\thispagestyle{#1}\input{\jobname.exm}}{\typeout{Class exam Warning: Questions file created. Rerun to get expected output.}}
\endgroup
\immediate\openout\examfile=\jobname.exm
}
\AtEndDocument{
\immediate\closeout\examfile
}
\newcommand\create@environment[1]{
\newenvironment{my#1}{%
\begin{#1}
\immediate\write\examfile{\string\begin{#1}}
}{%
\immediate\write\examfile{\string\end{#1}}
\end{#1}
}
}
\newcommand\create@item[1]{
\expandafter\newcommand\csname my#1\endcsname[2]{%
\if\relax\detokenize{##1}\relax
\csname #1\endcsname ##2
\immediate\write\examfile{\string\csname \space #1\string\endcsname\relax \unexpanded{##2}}%
\else
\csname #1\endcsname[##1] ##2
\immediate\write\examfile{\string\csname \space #1\string\endcsname[##1] \unexpanded{##2}}%
\fi
}
}
\newcommand\create@titleditem[1]{
\expandafter\newcommand\csname my#1\endcsname[3]{%
\if\relax\detokenize{##2}\relax
\csname #1\endcsname{##1} ##3
\immediate\write\examfile{\string\csname \space #1\string\endcsname\unexpanded{\begingroup ##1\endgroup}\relax \unexpanded{##3}}%
\else
\csname #1\endcsname{##1}[##2] ##3
\immediate\write\examfile{\string\csname \space #1\string\endcsname\unexpanded{##1}[##2] \unexpanded{##3}}%
\fi
}
}
\create@environment{questions}
\create@environment{parts}
\create@environment{subparts}
\create@environment{subsubparts}
\create@item{question}
\create@item{part}
\create@item{subpart}
\create@item{subsubpart}
\create@titleditem{titledquestion}
\newcommand\insertClearPage{\immediate\write\examfile{\string\clearpage}}
Aquí hay un MWE que muestra cómo usarlo. Creará otro archivo y, en una segunda pasada, copiará las preguntas en la parte superior.
\documentclass{examExt}
\usepackage{amsmath, amssymb}
\begin{document}
\insertQuestions
\clearpage
\begin{myquestions}
\myquestion{2}{This is a question $3\in\mathbb{R}$}
\begin{solutionbox}{3in}
This is a solution
\end{solutionbox}
\begin{myparts}
\mypart{2}{This is a part}
\begin{solutionbox}{3in}
This is a solution
\end{solutionbox}
\end{myparts}
\end{myquestions}
\end{document}
Respuesta2
Aquí lo presento \Calculate{}
para proporcionar el problema y \Solution{}
proporcionar la respuesta. Tenga en cuenta que \Solution
automáticamente repite el "problema" como la primera línea, y el argumento opcional de []
suprime el salto de línea que normalmente seguiría (que se muestra en el elemento 1).
\documentclass[10pt]{amsart}
\usepackage{tabstackengine,enumitem}
\newcommand\Calculate[1]{Calculate $#1$\def\Question{#1}}
\newcommand\Solution[2][\\]{Solution: \Longunderstack[l]{\Question#1#2}}
\stackMath
% TO PROVIDE BLANK SOLUTION
%\renewcommand\Solution[2][\\]{Solution: \setbox0=\hbox{%
% \Longunderstack[l]{\Question#1#2}}\rule[-\dp0]{0pt}{\dimexpr\ht0+\dp0}}
% TO PROVIDE NO SOLUTION
%\renewcommand\Solution[2][\\]{}
\begin{document}
\sffamily
\begin{enumerate}[listparindent=0in,itemsep=5pt]
\item \Calculate{1 + 2}
\Solution[]{=3}
\item \Calculate{1 + 2 + 3}
\Solution{=3+3\\=6}
\item \Calculate{1+2+3+4}
\Solution{=3+3+4\\=6+4\\=10}
\item \Calculate{1+2+3+4+5}
\Solution{=3+3+4+5\\=6+4+5\\=10+5\\=15}
\item
\end{enumerate}
\end{document}
Para borrar las soluciones, simplemente descomente las líneas para redefinirlas \Solution
como
\renewcommand\Solution[2][\\]{Solution: \setbox0=\hbox{%
\Longunderstack[l]{\Question#1#2}}\rule[-\dp0]{0pt}{\dimexpr\ht0+\dp0}}
LlegarNosolución, simplemente descomente la otra línea para redefinirla \Solution
como
\renewcommand\Solution[2][\\]{}
ALTERNO
Si no desea tener que escribir =
al principio de cada línea de la solución, puede lograrlo, pero solo renunciando a la capacidad de argumento opcional de suprimir el avance de línea después de la reformulación del problema (compare el elemento 1).
\documentclass[10pt]{amsart}
\usepackage{tabstackengine,enumitem}
\def\stackalignment{l}
\newcommand\Calculate[1]{Calculate $#1$\def\Question{#1}}
\newcommand\Solution[1]{Solution: \stackunder{\Question}
{\tabbedLongunderstack[l]{#1}}}
\stackMath
\TABstackMath
\TABstackMathstyle{=}
% TO PROVIDE BLANK SOLUTION
%\renewcommand\Solution[1]{Solution: \setbox0=\hbox{\stackunder{\Question}%
% {\tabbedLongunderstack[l]{#1}}}\rule[-\dp0]{0pt}{\dimexpr\ht0+\dp0}}
% TO PROVIDE NO SOLUTION
%\renewcommand\Solution[1]{}
\begin{document}
\sffamily
\begin{enumerate}[listparindent=0in,itemsep=5pt]
\item \Calculate{1 + 2}
\Solution{3}
\item \Calculate{1 + 2 + 3}
\Solution{3+3\\6}
\item \Calculate{1+2+3+4}
\Solution{3+3+4\\6+4\\10}
\item \Calculate{1+2+3+4+5}
\Solution{3+3+4+5\\6+4+5\\10+5\\15}
\item
\end{enumerate}
\end{document}
Respuesta3
Podrías usar la exam
clase, que también te permitiría dejar espacio para la solución. También te permite asignar puntos a preguntas o partes de preguntas (que omito aquí).
\documentclass[
answers
]{exam}
\usepackage{mathtools}
\begin{document}
\begin{questions}
\question Calculate \(1 + 2\)
\begin{solution}
\(1 + 2 = 3\)
\end{solution}
\question Calculate \(1 + 2 + 3\)
\begin{solution}
\begin{align*}
& 1 + 2 + 3\\
& = 3 + 3\\
& = 6
\end{align*}
\end{solution}
\end{questions}
\end{document}