I want to build a framework for sharing latex mathematics exercises. When trying to assemble exercises from different authors into one "homework assignment", I have a problem. How can I deal with their different macros and settings? Is there some way to do something like this:

enter image description here

I thought about the preview and the minipage package, but I don't quite know how they could do the job.

It is important that exercise 1 and 2 might have conflicting macros, so the environments must be completely isolated and self contained. Also the exercises should be page-breakable.

Does anyone have an idea how to solve this?

Edit: Pseudocode example




\documentclass[preview, varwidth=500]{standalone} 





Since this obviously doesn't work, I might use a parser to remove the documentclass and move the packages to the header and use \begingroup ... \endgroup to isolate the rest.

closed as unclear what you're asking by user31729, Stefan Pinnow, Mensch, Zarko, user36296 May 27 '16 at 21:51

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Build a framework that compiles them separately into pdfs, then include the pdfs in the final document? That won't meet the page-breakable requirement, though. – Ethan Bolker Aug 9 '15 at 15:54
  • if you can add some example code it may be more clear – touhami Aug 9 '15 at 16:14
  • related tex.stackexchange.com/questions/222861/… – touhami Aug 9 '15 at 16:16
  • @EthanBolker I thought about something like this. I definitely wouldn't build a pdf merger myself because I'm sure there already is something like this? I couldn't find one though, that makes it look nice. As you say the page breaks are a problem with trivial implementations of pdf mergers. – bersling Aug 9 '15 at 16:43
  • 1
    @user3022127: Do you have the permission to use exercises and code from other authors at all? ;-) – user31729 Aug 9 '15 at 21:30

Here's a proposition with tcblisting stuff, which is very powerful, but I restricted to the basic usage -- it can be easily extended with a lot of options.

Be sure to use the listing only option to the environment, otherwise tcolorbox tries to typeset both code and its LaTeX output. This must fail with of course with things like \documentclass, \usepackage{...}, \begin{document}...\end{document}.

The 2nd argument is for specification of the task, the 3rd argument is meant to indicate a copyright.

Better ways for this: Use\DeclareTotalTColorBox and related commands.



\newtcblisting[auto counter,number within=section]{texexercise}[3][]{listing only,listing options={language={TeX}}, colback=white!40!yellow, enhanced jigsaw, sharp corners, title={\TeX\ exercise \thetcbcounter\ #2\notblank{#3}{\hfill \textcopyright #3}{}},coltitle={black},colbacktitle={blue!20!white},#1}

\section{Easy stuff}

\begin{texexercise}{Find the errors in this task}{By me!}

\begin{texexercise}{Complete and/or correct the following code}{}


enter image description here

Since the question itself is unclear: There are many possibilities to typeset questions and solutions with tcolorbox and its recording feature.

  • I don't think the OP wants to typeset the code. They want to typeset the result of the code i.e. it is maths exercises being typeset and not LaTeX exercises. I might be wrong, though, as I find the question rather confusing. – cfr May 27 '16 at 23:36
  • @cfr: Well, it's confusing (or contradicting), because the screen shot tells of macro exercises etc. – user31729 May 27 '16 at 23:37
  • I think it means the macros used by Exercise 1, say, and not the macros in Exercise 1. But it is not a clear question at all. – cfr May 27 '16 at 23:42
  • @cfr: I try to provide some a similarly unclear answer about the math stuff tomorrow (well, today, actually) – user31729 May 27 '16 at 23:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.