"Ans" 환경에 그리드를 삽입하는 방법 마치 손으로 완성할 것 같은?

"Ans" 환경에 그리드를 삽입하는 방법 마치 손으로 완성할 것 같은?

저는 몇 달 전부터 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환경에서 자동으로 그리드를 추가하도록 할 수 있습니다. 그리드를 사용하면 쉽게 그릴 수 있습니다.TikZ, 따라서 주요 문제는 그리드의 크기를 아는 것, 즉 페이지 하단이 어디에 있는지 아는 것입니다. 다행히도,tikzpagenodes패키지는 노드를 정의 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}

관련 정보