0

I would like to modify the below template so that it prints out 1 problem per sheet. Example: Problem 1 on pages 1-3, problem 2 on 5-6 and nothing on page 4. Another Example: Problem 1 on Pages 1-2, problem 2 on 3-5, nothing on p6, and problem 3 on p7.

The template is

\documentclass[letterpaper,12pt,twoside]{article}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[letterpaper, top = 1.5in, left = 1in, right = 1in, bottom = 1.5in]  
\usepackage{fancyhdr}       
\usepackage{amsfonts,amsmath,amsthm,amssymb}
\usepackage{parskip}

\title{}
\author{Author}     
\date{\today}               

\makeatletter               
\let\Author\@author         
\let\Date\@date             
\makeatother

\newcommand{\Problem}{\relax}
\newcounter{problemcount}
\newcommand{\nextproblem}[1]{\renewcommand{\Problem}{#1}\setcounter{equation {0}\setcounter{page}{0}}

\pagestyle{fancy}
\lhead{\Problem}
\chead{}
\rhead{
\Author
\\
Class
\\
Section
\\
\Date
}

\renewcommand{\headrulewidth}{0.4pt}
\setlength{\headheight}{56.2pt}
\setlength{\parindent}{0pt}

\makeatother

\begin{document}
\nextproblem{Problem 1}
\begin{proof}\begin{align*}1+1&=2\\2&=2\end{align*}\end{proof}
\newpage

\nextproblem{Problem 2}\begin{proof}\begin{align*}1+1&=2\\2&=2\end{align*}\end{proof}

\end{document}
3
  • Use \cleardoublepage at the end of each problem.
    – cfr
    Commented Sep 21, 2014 at 17:59
  • Please fix your code so that it compiles!
    – cfr
    Commented Sep 21, 2014 at 18:00
  • Also, what does this have to do with conditionals?
    – cfr
    Commented Sep 21, 2014 at 18:11

1 Answer 1

3

This fixes your example, cleans up the preamble a bit and implements the \cleardoublepage:

\documentclass[letterpaper,12pt,twoside]{article}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[top = 1.5in, left = 1in, right = 1in, bottom = 1.5in, headheight=56.2pt]{geometry}% tell geometry about the head height
\usepackage{fancyhdr}
\usepackage{amsfonts,amsmath,amsthm,amssymb}
\usepackage{parskip}% already sets parindent to zero - no need to do it yourself later as well
\usepackage{kantlipsum}

\title{}
\author{Author}
\date{\today}

\makeatletter
\let\Author\@author% consider using the titling package if you need commands like this
\let\Date\@date
\makeatother

\newcommand{\Problem}{\relax}
\newcounter{problemcount}
\newcommand{\nextproblem}[1]{%
  \cleardoublepage
  \renewcommand{\Problem}{#1}%
  \setcounter{equation}{0}}% if you want problem 2 on pages 5-6, better not reset the page count to zero!

\pagestyle{fancy}
\lhead{\Problem}
\chead{}
\rhead{
  \Author
  \\
  Class
  \\
  Section
  \\
  \Date
}

\makeatother

\begin{document}
  \nextproblem{Problem 1}
  \begin{proof}\begin{align*}1+1&=2\\2&=2\end{align*}\end{proof}
  \kant[1-8]

  \nextproblem{Problem 2}\begin{proof}\begin{align*}1+1&=2\\2&=2\end{align*}\end{proof}
  \kant[9-14]

\end{document}

Problem 1 on pages 1-3, blank page 4, problem 2 on pages 5-6

Update

Spurred by Christopher Hupfer's suggestion, this is an attempt to clean up the code a bit more. Since it is not entirely clear what you are trying to do, this may not be exactly what you want. However, it should at least give you some ideas.

I use \newtheorem as Christopher Hupfer suggested. Rather than create an additional \nextproblem macro, I have used etoolbox to append commands to the start and end of the problem environment. The header then uses the problem number, which amsthm manages automatically. In this version, page 4 is entirely empty - without even header or footer. If you do not want this, remove \thispagestyle{empty}. I have also used titling to ensure that the values from \author etc. are available throughout, and adapted the header to use the macros provided by that package.

\documentclass[letterpaper,12pt,twoside]{article}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[top = 1.5in, left = 1in, right = 1in, bottom = 1.5in, headheight=56.2pt]{geometry}% tell geometry about the head height
\usepackage{fancyhdr}
\usepackage{amsfonts,amsmath,amsthm,amssymb}
\usepackage{parskip}% already sets parindent to zero - no need to do it yourself later as well
\usepackage{etoolbox,titling}
\usepackage{kantlipsum}

\title{}
\author{Author}
\date{\today}

\newtheorem{problem}{Problem}
\newcommand{\nextproblem}[1]{%
  \cleardoublepage\thispagestyle{fancy}%
  \setcounter{equation}{0}}% if you want problem 2 on pages 5-6, better not reset the page count to zero!

\AtBeginEnvironment{problem}{%
  \cleardoublepage
  \setcounter{equation}{0}}
\AtEndEnvironment{problem}{%
  \clearpage
  \thispagestyle{empty}}

\pagestyle{fancy}
\lhead{Problem \theproblem}
\chead{}
\rhead{
  \theauthor
  \\
  Class
  \\
  Section
  \\
  \thedate
}

\begin{document}
  \begin{problem}
    \begin{proof}\begin{align*}1+1&=2\\2&=2\end{align*}\end{proof}
    \kant[1-8]
  \end{problem}

  \begin{problem}
    \begin{proof}\begin{align*}1+1&=2\\2&=2\end{align*}\end{proof}
    \kant[9-14]
  \end{problem}
\end{document}

Possible implementation with somewhat cleaner code

3
  • Would a \newtheorem{Problem} not be much better? I know, this would change a lot in the OP ;-)
    – user31729
    Commented Sep 21, 2014 at 18:28
  • @ChristianHupfer I'm really not sure. I could not figure out what \Problem was intended to do or how it is being used in the document. So while I agree this probably isn't great, I don't have any real idea what would be better. (Right now \Problem gets defined but doesn't seem to ever be used. I assume it is used elsewhere but the purpose is not at all clear to me.)
    – cfr
    Commented Sep 21, 2014 at 20:38
  • The whole template is a mess, actually (You made the best of it ;-))
    – user31729
    Commented Sep 21, 2014 at 20:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .