From 89254042b68b23ffae35800172b5de13786b5451 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 11 Jun 2016 23:15:38 +0000 Subject: exsol (5jun16) git-svn-id: svn://tug.org/texlive/trunk@41377 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/exsol/exsol.sty | 240 ++++++++++++++++++++++++---- 1 file changed, 210 insertions(+), 30 deletions(-) (limited to 'Master/texmf-dist/tex/latex') diff --git a/Master/texmf-dist/tex/latex/exsol/exsol.sty b/Master/texmf-dist/tex/latex/exsol/exsol.sty index 4afcf4b74b8..15b81643381 100644 --- a/Master/texmf-dist/tex/latex/exsol/exsol.sty +++ b/Master/texmf-dist/tex/latex/exsol/exsol.sty @@ -8,7 +8,7 @@ %% %% This is a generated file. %% -%% Copyright (C) 2014 by Walter Daems +%% Copyright (C) 2015 by Walter Daems %% %% This file may be distributed and/or modified under the conditions of %% the LaTeX Project Public License, either version 1.3 of this license @@ -22,10 +22,14 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{exsol} - [2014/08/31 v0.91 ExSol - Exercises and Solutions package (DMW)] + [2016/05/13 v1.2 ExSol - Exercises and Solutions package (DMW)] +\RequirePackage{ifmtarg} \RequirePackage{fancyvrb} \RequirePackage{ifthen} \RequirePackage{kvoptions} +\RequirePackage{multicol} +\DeclareBoolOption[false]{local} +\DeclareBoolOption[false]{nolabels} \DeclareStringOption[normalsize]{exercisesfontsize} \DeclareBoolOption[false]{exerciseaslist} \DeclareBoolOption[false]{copyexercisesinsolutions} @@ -33,9 +37,9 @@ \ProcessKeyvalOptions* \newcommand{\exercisesfontsize}{\csname \exsol@exercisesfontsize\endcsname} \newlength{\exsolexercisesaboveskip} -\setlength{\exsolexercisesaboveskip}{1ex plus 1pt minus 1pt} +\setlength{\exsolexercisesaboveskip}{0ex plus 1pt minus 1pt} \newlength{\exsolexercisesbelowskip} -\setlength{\exsolexercisesbelowskip}{1ex plus 1pt minus 1pt} +\setlength{\exsolexercisesbelowskip}{0ex plus 1pt minus 1pt} \newlength{\exsolexercisetopbottomsep} \setlength{\exsolexercisetopbottomsep}{0pt plus 0pt minus 1pt} \newlength{\exsolexerciseleftmargin} @@ -53,25 +57,44 @@ \newlength{\exsolexerciseparsep} \setlength{\exsolexerciseparsep}{\parskip} \AtBeginDocument{ + \typeout{Writing solutions to solution file \jobname.sol.tex} \newwrite\solutionstream \immediate\openout\solutionstream=\jobname.sol.tex + \typeout{Using intermediate exercise file \jobname.exc.tex} \newwrite\exercisestream + \typeout{Writing formulae to formula collection file \jobname.fc.tex} + \newwrite\formulacollectionstream + \immediate\openout\formulacollectionstream=\jobname.fc.tex + \typeout{Using intermediate formula file \jobname.for.tex} + \newwrite\formulastream } \AtEndDocument{ + \immediate\closeout\formulacollectionstream \immediate\closeout\solutionstream } -\newcounter{exercise}[subsection] +\newcommand\loadSolutions{ + \immediate\closeout\solutionstream + \input{\jobname.sol.tex} +} +\newcounter{exerciseseries}[subsubsection] +\setcounter{exerciseseries}{0} +\renewcommand{\theexerciseseries}{\arabic{exerciseseries}} +\newcounter{exercise}[exerciseseries] \setcounter{exercise}{0} \renewcommand{\theexercise}{% + \ifexsol@local + \arabic{exerciseseries}.\arabic{exercise}% + \else \@ifundefined{c@chapter}{}{\if0\arabic{chapter}\else\arabic{chapter}.\fi}% \if0\arabic{section}\else\arabic{section}\fi% \if0\arabic{subsection}\else.\arabic{subsection}\fi% \if0\arabic{subsubsection}\else.\arabic{subsubsection}\fi% \if0\arabic{exercise}\else% - \@ifundefined{c@chapter}% - {\if0\arabic{section}\else-\fi}% - {-}% - \arabic{exercise}% + \@ifundefined{c@chapter}% + {\if0\arabic{section}\else-\fi}% + {-}% + \arabic{exercise}% + \fi \fi } \newcommand{\GPES@write@detok}[1]{% @@ -81,18 +104,24 @@ \newcommand{\GPESS@write@detok}[1]{% \GPES@write@detok{#1}% \GPSS@write@detok{#1}}% +\newcommand{\GPFORCOL@write@detok}[1]{% + \immediate\write\formulacollectionstream{\detokenize{#1}}% + \immediate\write\formulastream{\detokenize{#1}}}% +\newcommand{\GPFORCOLONLY@write@detok}[1]{% + \immediate\write\formulacollectionstream{\detokenize{#1}}}% \def\exercise{\FV@Environment{}{exercise}} \def\FVB@exercise{% \refstepcounter{exercise}% \immediate\openout\exercisestream=\jobname.exc.tex - \ifexsol@copyexercisesinsolutions - \typeout{Writing exercise to \jobname.sol.tex} - \immediate\write\solutionstream{\string\par---\string\newline - \string\textbf\string{\exercisename{} \theexercise \string}} + \ifexsol@local \else - \immediate\write\solutionstream{\string\par---\string\newline} \fi - \immediate\write\exercisestream{\string\begin{exsol@exercise}} + \ifexsol@copyexercisesinsolutions + % WDSC tofix + % \typeout{Writing exercise to \jobname.sol.tex} + \immediate\write\solutionstream{\string\begin{exsol@exercise}{\theexercise}} + \fi + \immediate\write\exercisestream{\string\begin{exsol@exercise}{\theexercise}} \@bsphack \begingroup \FV@UseKeyValues @@ -113,13 +142,13 @@ \endgroup\@esphack \immediate\write\exercisestream{\string\end{exsol@exercise}} \ifexsol@copyexercisesinsolutions - \immediate\write\solutionstream{\string~\string\newline} + \immediate\write\solutionstream{\string\end{exsol@exercise}} \fi \immediate\closeout\exercisestream \input{\jobname.exc.tex} } \DefineVerbatimEnvironment{exercise}{exercise}{} -\newenvironment{exsol@exercise}[0] +\newenvironment{exsol@exercise}[1] {% \ifthenelse{\boolean{exsol@minipage}}{\begin{minipage}[t]{\textwidth}}{}% \ifthenelse{\boolean{exsol@exerciseaslist}} @@ -135,9 +164,11 @@ \setlength{\parsep}{\exsolexerciseparsep} \setlength{\labelsep}{\exsolexerciselabelsep} \setlength{\labelwidth}{\exsolexerciselabelwidth}} - \item[\textit{~\exercisename{} \theexercise:~}] + \item[\ifexsol@nolabels~#1:\else% + \subparagraph{\exercisename{}~#1:}\fi] }% - {\textit{\exercisename{} \theexercise:}} + {\ifexsol@nolabels #1:\else% + \subparagraph{\exercisename{}~#1:}\fi} } {% \ifthenelse{\boolean{exsol@exerciseaslist}}% @@ -146,13 +177,11 @@ } \def\solution{\FV@Environment{}{solution}} \def\FVB@solution{% - \typeout{Writing solution to \jobname.sol.tex} - \immediate\write\solutionstream{\string\textbf\string{\solutionname{}\string}} + %\typeout{Writing solution to \jobname.sol.tex} \ifexsol@copyexercisesinsolutions - \immediate\write\solutionstream{\string\newline} + \immediate\write\solutionstream{\string\begin{exsol@solution}{}} \else - \immediate\write\solutionstream{\string\textbf\string{\theexercise\string}% - \string\newline} + \immediate\write\solutionstream{\string\begin{exsol@solution}{\theexercise}} \fi \@bsphack \begingroup @@ -166,44 +195,187 @@ \let\@noligs\relax \FV@Scan } -\def\FVE@solution{\endgroup\@esphack} +\def\FVE@solution{ + \endgroup\@esphack + \immediate\write\solutionstream{\string\end{exsol@solution}} +} \DefineVerbatimEnvironment{solution}{solution}{} -\newenvironment{exercises} -{\par\exercisesfontsize\rule{.25\linewidth}{0.15mm}\vspace*{\exsolexercisesaboveskip}\\*% - \textbf{\normalsize \exercisesname}} -{\vspace*{-\baselineskip}\vspace*{\exsolexercisesbelowskip}\rule{.25\linewidth}{0.15mm}\par} +\newenvironment{exsol@solution}[1] +{% + \ifthenelse{\boolean{exsol@minipage}}{\begin{minipage}[t]{\textwidth}}{}% + \ifthenelse{\boolean{exsol@exerciseaslist}} + {\begin{list}% + {% + }% + {% + \setlength{\topsep}{\exsolexercisetopbottomsep}% + \setlength{\leftmargin}{\exsolexerciseleftmargin}% + \setlength{\rightmargin}{\exsolexerciserightmargin}% + \setlength{\listparindent}{\exsolexerciseparindent}% + \setlength{\itemindent}{\exsolexerciseitemindent}% + \setlength{\parsep}{\exsolexerciseparsep} + \setlength{\labelsep}{\exsolexerciselabelsep} + \setlength{\labelwidth}{\exsolexerciselabelwidth}} + \item[\ifexsol@nolabels #1:\else% + \subparagraph{\solutionname{}\@ifmtarg{#1}{}{~}#1:}\fi] + }% + {\ifexsol@nolabels #1:\else% + \subparagraph{\solutionname{}\@ifmtarg{#1}{}{~}#1:}\fi} + } + {% + \ifthenelse{\boolean{exsol@exerciseaslist}}% + {\end{list}}{}% + \ifthenelse{\boolean{exsol@minipage}}{\end{minipage}}{\par}% +} +\define@key{exercises}{columns}{\renewcommand\columncount{#1}} +\define@key{exercises}{exsubrule}{\renewcommand\exsubrule{#1}} +\define@key{exercises}{solsubrule}{\renewcommand\solsubrule{#1}} +\define@key{exercises}{subrule}{\renewcommand\exsubrule{#1}\renewcommand\solsubrule{#1}} +\newenvironment{exercises}[1][] +{ + \newcommand\columncount{1} % default + \newcommand\exsubrule{} % default + \newcommand\solsubrule{} % default + \setkeys{exercises}{#1} + \par\exercisesfontsize\rule{.25\linewidth}{0.15mm}% + \vspace*{\exsolexercisesaboveskip}% + \paragraph{\exercisesname}~\par + \ifthenelse{\columncount > 1}{\begin{multicols}{\columncount}}{} + } + { + \ifthenelse{\columncount > 1}{\end{multicols}}{}\relax + \vspace*{-\baselineskip}\vspace*{\exsolexercisesbelowskip}% + %\rule{.25\linewidth}{0.15mm} + \exsubrule\par} +\define@key{exerciseseries}{columns}{\renewcommand\columncount{#1}} +\define@key{exerciseseries}{exsubrule}{\renewcommand\exsubrule{#1}} +\define@key{exerciseseries}{solsubrule}{\renewcommand\solsubrule{#1}} +\define@key{exerciseseries}{subrule}{\renewcommand\exsubrule{#1}\renewcommand\solsubrule{#1}} +\newenvironment{exerciseseries}[2][] +{ + \refstepcounter{exerciseseries}% + \newcommand\columncount{1} % default + \newcommand\exsubrule{} % default + \newcommand\solsubrule{} % default + \setkeys{exerciseseries}{#1} + \paragraph{\seriesname~\theexerciseseries:~#2}~\par + \ifthenelse{\columncount > 1}{\begin{multicols}{\columncount}}{} + \immediate\write\solutionstream{\string\begin\string{solutionseries\string}% + \string[#1\string]\string{#2\string}\string{\theexerciseseries\string}} + } + { + \ifthenelse{\columncount > 1}{\end{multicols}}{}\relax + \exsubrule\par + \immediate\write\solutionstream{\string\end\string{solutionseries\string}} +} +\newenvironment{solutionseries}[3][] +{ + \newcommand\columncount{1} % default + \newcommand\exsubrule{} % default + \newcommand\solsubrule{} % default + \setkeys{exercises}{#1} + \paragraph{\seriesname~#3}~\par + \ifthenelse{\columncount > 1}{\begin{multicols}{\columncount}}{} + } + { + \ifthenelse{\columncount > 1}{\end{multicols}}{} + \solsubrule\par +} +\def\informulacollection{\FV@Environment{}{informulacollection}} +\def\FVB@informulacollection{% + \immediate\openout\formulastream=\jobname.for.tex + %\typeout{Writing formula to \jobname.for.tex and \jobname.fc.tex} + \@bsphack + \begingroup + \FV@UseKeyValues + \FV@DefineWhiteSpace + \def\FV@Space{\space}% + \FV@DefineTabOut + \let\FV@ProcessLine\GPFORCOL@write@detok % + \relax + \let\FV@FontScanPrep\relax + \let\@noligs\relax + \FV@Scan + } +\def\FVE@informulacollection{ + \endgroup\@esphack + \immediate\closeout\formulastream + \input{\jobname.for.tex} +} +\DefineVerbatimEnvironment{informulacollection}{informulacollection}{} +\def\informulacollectiononly{\FV@Environment{}{informulacollectiononly}} +\def\FVB@informulacollectiononly{% + %\typeout{Writing special to \jobname.fc.tex} + \@bsphack + \begingroup + \FV@UseKeyValues + \FV@DefineWhiteSpace + \def\FV@Space{\space}% + \FV@DefineTabOut + \let\FV@ProcessLine\GPFORCOLONLY@write@detok % + \relax + \let\FV@FontScanPrep\relax + \let\@noligs\relax + \FV@Scan + } +\def\FVE@informulacollectiononly{ + \endgroup\@esphack +} +\DefineVerbatimEnvironment{informulacollectiononly}{informulacollectiononly}{} \newcommand{\exercisename}{Exercise} \newcommand{\exercisesname}{Exercises} \newcommand{\solutionname}{Solution} \newcommand{\solutionsname}{Solutions} +\newcommand{\seriesname}{Series} \addto\captionsdutch{% \renewcommand{\exercisename}{Oefening}% \renewcommand{\exercisesname}{Oefeningen}% \renewcommand{\solutionname}{Oplossing}% \renewcommand{\solutionsname}{Oplossingen}% + \renewcommand{\seriesname}{Reeks}% } \addto\captionsgerman{% \renewcommand{\exercisename}{Aufgabe}% \renewcommand{\exercisesname}{Aufgaben}% \renewcommand{\solutionname}{L\"osung}% \renewcommand{\solutionsname}{L\"osungen}% + \renewcommand{\seriesname}{Serie}% +} +\addto\captionsngerman{% + \renewcommand{\exercisename}{Aufgabe}% + \renewcommand{\exercisesname}{Aufgaben}% + \renewcommand{\solutionname}{L\"osung}% + \renewcommand{\solutionsname}{L\"osungen}% + \renewcommand{\seriesname}{Serie}% } \addto\captionsfrench{% \renewcommand{\exercisename}{Exercice}% \renewcommand{\exercisesname}{Exercices}% \renewcommand{\solutionname}{Solution}% \renewcommand{\solutionsname}{Solutions}% + \renewcommand{\seriesname}{Serie}% } \addto\captionsfinnish{ \renewcommand{\exercisename}{Teht\"av\"a}% \renewcommand{\exercisesname}{Teht\"avi\"a}% \renewcommand{\solutionname}{Ratkaisu}% \renewcommand{\solutionsname}{Ratkaisut}% + \renewcommand{\seriesname}{Sarja} +} +\addto\captionsspanish{% + \renewcommand{\exercisename}{Ejercicio}% + \renewcommand{\exercisesname}{Ejercicios}% + \renewcommand{\solutionname}{Soluci\'on}% + \renewcommand{\solutionsname}{Soluciones}% + \renewcommand{\seriesname}{Serie}% } +\ifexsol@local +\else \let\exsol@@makechapterhead\@makechapterhead \def\@makechapterhead#1{% - \immediate\write\solutionstream{\string\chapter{#1}}% \exsol@@makechapterhead{#1} + \immediate\write\solutionstream{\string\setcounter{chapter}{\arabic{chapter}}% + \string\chapter{#1}}% } \ifdefined\frontmatter \let\exsol@@frontmatter\frontmatter @@ -226,6 +398,14 @@ \exsol@@backmatter } \fi +\ifdefined\appendix + \let\exsol@@appendix\appendix + \def\appendix{% + \immediate\write\solutionstream{\string\appendix}% + \exsol@@appendix + } +\fi +\fi \newcommand{\noexercisesinchapter} { \immediate\write\solutionstream{No exercises in this chapter} -- cgit v1.2.3