About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Account
Latest news 2024-12-13: Ebook sale (12th December 2024 – 1st January 2025): cybercrime fiction short stories Unsocial Media and Smile for the Camera free; crime fiction short story The Briefcase free; short story noir crime fiction I’ve Heard the Mermaid Sing free; crime fiction novel The Private Enemy US$1.99; illustrated children’s story The Foolish Hedgehog US$0.99.

Random selection with pgfmath.sty and probsoln.sty

\documentclass{article}

\usepackage{pgfmath}
\usepackage{probsoln}

% set random seed
\pgfmathsetseed{\year}

\begin{defproblem}{easy.diff}%
  \ifundef\easydiffcoeff
  {%
    \pgfmathrandominteger{\easydiffcoeff}{2}{10}% generate random coefficient
    \global\let\easydiffcoeff\easydiffcoeff % make it global
  }
  {}% already been defined
  \begin{onlyproblem}
  % question
  Differentiate with respect to $x$:
  \[
    y = \sin(\easydiffcoeff x)
  \]
  \end{onlyproblem}
  \begin{onlysolution}
  % solution
  $ y' = \easydiffcoeff\cos(\easydiffcoeff x) $
  \end{onlysolution}
\end{defproblem}

\begin{document}

\section{Questions}

\begin{enumerate}
\foreachproblem{\item\thisproblem}
\end{enumerate}

\showanswers
\section{Solutions}
\begin{enumerate}
\foreachsolution{\item\thisproblem}
\end{enumerate}

\end{document}


Download probsoln-rand.tex or probsoln-rand.pdf.

© 2015 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs