我想修改下面的模板,以便每张纸打印出 1 个问题。例如:问题 1 在第 1-3 页,问题 2 在第 5-6 页,第 4 页上没有任何内容。另一个示例:问题 1 在第 1-2 页,问题 2 在第 3-5 页,第 6 页上没有任何内容,问题 3 在第 7 页。
模板是
\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}
答案1
这修复了您的示例,稍微清理了序言并实现了\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}
更新
受 Christopher Hupfer 建议的启发,本文尝试进一步整理代码。由于您不太清楚自己想要做什么,因此这可能不是您想要的。但是,它至少应该能给您一些启发。
我按照 Christopher Hupfer 的建议使用。我\newtheorem
没有创建额外的宏,而是习惯于将命令附加到环境的开始和结束。然后,标题使用问题编号,该编号会自动管理。在此版本中,第 4 页完全是空的 - 甚至没有页眉或页脚。如果您不想要这样,请删除。我还习惯于确保等中的值始终可用,并调整了标题以使用该包提供的宏。\nextproblem
etoolbox
problem
amsthm
\thispagestyle{empty}
titling
\author
\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}