自从几个月前开始学习 LaTeX 以来,我一直在使用该网站,发现它非常有用,感谢大家。
我的问题是,我大学里的一些教授不喜欢打字作业,因为似乎有些学生从网上复制粘贴答案,而我们被要求手工解决问题。现在,我仍然想将问题陈述保存在乳胶中,然后打印出来并手工完成,从那时起我就一直这样做,但发现没有网格太乱了。
我希望文件看起来像图中那样,但是我通过将文档导出为 PDF 并使用一些“设计软件”来绘制网格来实现这一点,而在作业的每一页上都这样做太耗时了(通常长达 8 页)。 我将给你留下一个源代码示例:
\documentclass[a4paper, 11pt]{article}
\usepackage{comment} % enables the use of multi-line comments (\ifx \fi)
\usepackage{fullpage} % changes the margin
\usepackage[a4paper, total={7in, 10in}]{geometry}
\usepackage[fleqn]{amsmath}
\usepackage{amssymb,amsthm} % assumes amsmath package installed
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{verbatim}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{arrows,calc,positioning}
\tikzset{
block/.style = {draw, rectangle,
minimum height=1cm,
minimum width=1.5cm},
input/.style = {coordinate,node distance=1cm},
output/.style = {coordinate,node distance=4cm},
arrow/.style={draw, -latex,node distance=2cm},
pinstyle/.style = {pin edge={latex-, black,node distance=2cm}},
sum/.style = {draw, circle, node distance=1cm},
}
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage[shortlabels]{enumitem}
\usepackage{indentfirst}
\usepackage{hyperref}
\renewcommand{\thesubsection}{\thesection.\alph{subsection}}
\newenvironment{problem}[2][Problem]
{ \begin{mdframed} \textbf{#1 #2} \\}
{ \end{mdframed}}
% Define solution environment
\newenvironment{solution}
{\textbf{\textit{Ans.\\ \\ \\}}}
{}
\renewcommand{\qed}{\quad\qedsymbol}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%Header-Make sure you update this information!!!!
\noindent
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\large\textbf{Homework - \#4} \hfill \textbf{Leonardo Sánchez} \\
Calculus 1 \hfill Civil \& Electromechanical Engineering \\
Professor Fang Jung Shiou \hfill Due date: $30^{th}$ March, 2020\\
Teacher Assistant: Paulo C. C. Galeano \\
\noindent\rule{7in}{2.8pt}
%Problem 1%
\begin{problem}{1 - (Section 11.3 Exs. 17 \& 21 - Page 726 - Stewart $8^{th}$ ed.)}
Determine whether the series is convergent or divergent.\\
a) $$\sum_{n=1}^\infty \cfrac{1}{n^2 + 4}.$$
b) $$\sum_{n=2}^{\infty}\cfrac{1}{n \ln n}.$$
\end{problem}
\begin{solution}
\pagebreak
\end{solution}
\end{document}
我读到环境不是那样工作的,也不可能在其中嵌套一些东西,所以如果我的问题表述得不好,有人可以指出我实现我所问问题的正确方法是什么吗?
提前致谢!
答案1
据我了解,您希望打印所有问题的网格,这样solution
环境就是多余的,相反,您可以让problem
环境自动添加网格。使用以下方法绘制网格很容易:蒂克兹,因此主要问题是知道网格应该有多大,或者说,知道页面底部的位置。幸运的是,tikzpage节点包定义了一个current page text area
节点,因此足以从当前位置到绘制一个网格(current page text area.south east)
。这样做的结果是:
需要一些额外的技巧来确保网格中只打印完整的方块,因为我认为在网格的右侧和底部有“半方块”看起来相当普通。为此,我将网格中的方块设为 20pt x 20pt,然后将坐标四舍五入为 20 的倍数。我本来希望以毫米为单位给出网格大小,但这很麻烦。
除了添加网格之外,我还添加了一个problem
计数器来自动对问题进行编号。其次,我建议使用环境,而不是手动输入 等——a)
我已经使用了b)
enumerate
\setlist
枚举项包,这样你就可以在 OP 中获得计数器。最后,我不会$$...$$
在问题中使用方程式,而是使用$\displaymath ...$
——请参阅为什么 \[ ... \] 比 $$ ... $$ 更可取?
以下是更新后的代码:
\documentclass[a4paper, 11pt]{article}
\usepackage{comment} % enables the use of multi-line comments (\ifx \fi)
\usepackage{fullpage} % changes the margin
\usepackage[a4paper, total={7in, 10in}]{geometry}
\usepackage[fleqn]{amsmath}
\usepackage{amssymb,amsthm} % assumes amsmath package installed
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{verbatim}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{arrows,calc,positioning}
\tikzset{
block/.style = {draw, rectangle,
minimum height=1cm,
minimum width=1.5cm},
input/.style = {coordinate,node distance=1cm},
output/.style = {coordinate,node distance=4cm},
arrow/.style={draw, -latex,node distance=2cm},
pinstyle/.style = {pin edge={latex-, black,node distance=2cm}},
sum/.style = {draw, circle, node distance=1cm},
}
\usepackage{tikzpagenodes}
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage[shortlabels]{enumitem}
\usepackage{indentfirst}
\usepackage{hyperref}
\renewcommand{\thesubsection}{\thesection.\alph{subsection}}
\newcounter{problem}
\newenvironment{problem}[2][Problem]
{ \refstepcounter{problem}%
\begin{mdframed}%
% the \detokenize checks to see if #2 is empty in which case
% nothing is printed
\textbf{#1 \theproblem\if\relax\detokenize{#2}\relax\else~-- (#2)\fi} \\
}
{ \end{mdframed}%
\textbf{\textit{Ans.}}\newline%
\begin{tikzpicture}[remember picture, overlay]
% some extra trickery to ensure that the grid only has whole squares
\draw[step=20pt, gray!40, thin]
let \p1=(current page text area.south east),
\n1={20*int(\x1/20)},
\n2={20*int(\y1/20)}
in (0,0) grid (\n1,\n2);
\end{tikzpicture}%
\pagebreak%
}
\usepackage{enumitem}
\setlist[enumerate]{label=\alph*)}
\renewcommand{\qed}{\quad\qedsymbol}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%Header-Make sure you update this information!!!!
\noindent
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\large\textbf{Homework - \#4} \hfill \textbf{Leonardo Sánchez} \\
Calculus 1 \hfill Civil \& Electromechanical Engineering \\
Professor Fang Jung Shiou \hfill Due date: $30^{th}$ March, 2020\\
Teacher Assistant: Paulo C. C. Galeano \\
\noindent\rule{7in}{2.8pt}
%Problem 1%
\begin{problem}{Section 11.3 Exs. 17 \& 21 - Page 726 - Stewart $8^{th}$ ed.}
Determine whether the series is convergent or divergent.
\begin{enumerate}
\item $\displaystyle \sum_{n=1}^\infty \cfrac{1}{n^2 + 4}$.
\item $\displaystyle \sum_{n=2}^{\infty}\cfrac{1}{n \ln n}$.
\end{enumerate}
\end{problem}
%Problem 2%
\begin{problem}{}
Determine whether the series is convergent or divergent.
\begin{enumerate}
\item $\displaystyle \sum_{n=1}^\infty \cfrac{1}{n^2 + 4}$.
\item $\displaystyle \sum_{n=2}^{\infty}\cfrac{1}{n \ln n}$.
\end{enumerate}
\end{problem}
%Problem 3%
\begin{problem}{Section 11.3 Exs. 17 \& 21 - Page 726 - Stewart $8^{th}$ ed.}
Determine whether the series is convergent or divergent.
\begin{enumerate}
\item $\displaystyle \sum_{n=1}^\infty \cfrac{1}{n^2 + 4}$.
\item $\displaystyle \sum_{n=2}^{\infty}\cfrac{1}{n \ln n}$.
\end{enumerate}
\end{problem}
\end{document}