把一个物品放在盒子里(家庭作业)

把一个物品放在盒子里(家庭作业)

我正在用这个enumerate环境做作业。下面,我先把问题写出来,然后把前两部分的答案写出来。

我想在问题周围添加一个方框。我该怎么做?

我尝试tikzmark按照建议使用这里但它不起作用(当我尝试使用数学模式时,框出现在错误的位置。请参阅文章末尾的代码

\documentclass{article}    
\usepackage{amsthm, amssymb, amsfonts, amsmath}

    \begin{document}

    \begin{enumerate}
    \item[1.]
    Consider the initial value problem 
    \[
     \frac{dy}{dx} = 1- (y-x)^2, \qquad y=0 \,\, \text{at} \,\, x=0
    \]
    \begin{enumerate}
     \item[(a)] Find a solution to the problem.
     \item[(b)] Regardless of (a), is the solution unique?
     \item[(c)] Write down the Picard iteration scheme for this ODE and find some $r>0$ for which it converges $|x|<r$.
     \item[(d)] Find some $R>0$ such that the Picard iterates \textit{diverge} for $|x|>R$. 


    \end{enumerate}

    \item[1a.]
       $\phi(x) = x$ is a solution, since $$\phi'(x) = 1 = 1 - (x-x)^2.$$

    \item[1b.]
       Note that the function $1-(y-x)^2$ is $C^{\infty}$ in both $x$ and $y$, and therefore given $x_0$, the function is locally Lipschitz in $y$, uniformly with respect to $x$ for $x$ in a neighborhood of $x_0$. Therefore such a solution is unique.
     \end{enumerate}
     \end{document}

使用这个tikzmark想法(没有用)

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{calc,shapes}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\begin{document}
\begin{enumerate}
\item[\tikzmark{bl} 1.]
Consider the initial value problem 
\[
 \frac{dy}{dx} = 1- (y-x)^2, \qquad y=0 \,\, \text{at} \,\, x=0
\]
\begin{enumerate}
 \item[(a)] Find a solution to the problem.
 \item[(b)] Regardless of (a), is the solution unique?
 \item[(c)] Write down the Picard iteration scheme for this ODE and find some $r>0$ for which it converges $|x|<r$.
 \item[(d)] Find some $R>0$ such that the Picard iterates \textit{diverge} for $|x|>R$. 
\end{enumerate}
\tikzmark{br}
\item[2.] Something not boxed
\item[3.] Also not boxed.
\end{enumerate}
\tikz[overlay,remember picture]{\draw[red]
  ($(bl)+(-0.2em,0.9em)$) rectangle
  ($(br)+(0.2em,-0.3em)$);}
\end{document}

编辑:当我尝试应用下面给出的建议时,出现了一个问题。tikzmark总是想把框放在最后一页。所以如果文档只有一页,那就没问题了。但如果它跳到两页,那就错了。

\documentclass{article}
\usepackage{tikz}
\usepackage{enumitem}
\usepackage{amsmath}
\usetikzlibrary{calc,shapes}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\begin{document}
\begin{enumerate}
\item
\leavevmode
\strut
\vadjust{%%
  \noindent
  \raisebox{\dimexpr\dp\strutbox+\ht\strutbox+1ex}[0pt][0pt]{\tikzmark{bl}}}%%
Consider the initial value problem 
\[
  \frac{dy}{dx} = 1- (y-x)^2, \qquad y=0 \,\, \text{at} \,\, x=0
\]
  \begin{enumerate}
   \item Find a solution to the problem.
   \item Regardless of (a), is the solution unique?
   \item Write down the Picard iteration scheme for this ODE and find some $r>0$ for which it converges $|x|<r$.
   \item Find some $R>0$ such that the Picard iterates \textit{diverge} for $|x|>R$. 
  \end{enumerate}

\leavevmode
\vadjust{%
  \noindent
  \hspace*{\dimexpr\textwidth+1ex}\tikzmark{br}}%%

  \item[1a.]
   $\phi(x) = x$ is a solution, since $$\phi'(x) = 1 = 1 - (x-x)^2.$$

\item[1b.]
   Note that the function $1-(y-x)^2$ is $C^{\infty}$ in both $x$ and $y$, and therefore given $x_0$, the function is locally Lipschitz in $y$, uniformly with respect to $x$ for $x$ in a neighborhood of $x_0$. Therefore such a solution is unique.

   \item[1c.]
    For convenience of notation, let us agree to label the constant function $0$ as the first Picard iterate $y_1(x)$ rather than the $0$th Picard iterate.
 \begin{align*}
  y_2(x) &= \int_0^x 1 - (y_1 - \xi)^2 d\xi = x - \frac13 x^3 \\
  y_3(x) &= \int_0^x 1 - (y_2(\xi) - \xi)^2 d\xi = \int_0^x 1 - \left(\frac13 \xi^3\right)^2 d\xi = x - \frac{1}{7\cdot 3^2}x^7 \\
  y_4(x) &= \dotsb = x - \frac{1}{15\cdot 7^2 \cdot 3^4}x^{15}\\
  \vdots \\
  y_n(x) &= x - \frac{1}{\prod_{k=1}^{n} (2^k-1)^{2^{(n-k)}}} x^{2^n - 1}
 \end{align*}
 The iterates will converge pointwise for $|x|<1$ (making no claim that that is the largest such interval). Since the modulus of the second term of $y_n$ is increasing with the modulus of $x$, we can say that the iterates will converge uniformly on compact subsets of the unit interval. (Given $[-a, a]\subseteq (-1,1)$, pick $n$ such that the second term of $y_n(a)$ is less than $\epsilon$; then this $n$ will work for all $x \in [-a, a]$.)

\item[1d.]
 Suppose we find an $x$ for which 
 \begin{align*}
  x-\frac{1}{\prod_{k=1}^{n} (2^k-1)^{2^{(n-k)}}} x^{2^n - 1}
  \end{align*}
 diverges to infinity (of course it will diverge iff the second term diverges). Then by the same considerations as in part (c), we can say that it will diverge for $\xi$ such that $|\xi| > |x|$.  

 Suppose we choose $x=4$. We have 

 \[
 y_n(x) = 4 - \frac{2^{2(2^n-1)}}{\prod_{k=1}^{n} (2^k-1)^{2^{(n-k)}}}.
 \]
 Note that the denominator satisfies
 \[
  (2^n-1)^{2^0}(2^{n-1}-1)^{2^1}\dotsb (2^2-1)^{2^{n-2}}\leq 2^{n2^0 + (n-1)2^1 + \dotsb + (2)2^{n-2}},
 \]
 where we have left out the final factor because it is equal to one. Some algebra tells us that $n2^0 + (n-1)2^1 + \dotsb + (2)2^{n-2} = 2^{n}+2^{n-1}-(n+2)\leq 2^{n+1}-(n+2)$. When we consider 
 \[
  \frac{2^{2(2^n-1)}}{\prod_{k=1}^{n} (2^k-1)^{2^{(n-k)}}} \geq \frac{C2^{2^{n+1}}}{2^{2^{n+1}-(n+2)}}=C2^{n+2},
 \]
 this clearly diverges.

 \item[2.] Let $y=\phi(x)$ and $y=\psi(x)$ be linearly independent solutions of the ODE $y'' + p(x)y' + q(x)y = 0$, where $p$ and $q$ are continuous on an open interval $I$. Prove the following statements:
 \begin{enumerate}
 \item[(a)] Suppose that $x_0 \in I$ is a zero of $\phi$, then $\psi$ cannot have a relative extremum value at $x_0$.
 \item[(b)] Suppose that $x_0$ and $x_1$ are two consecutive zeros of $\phi$ in $I$. Then $\psi$ must have a zero at some $\xi$, $x_0<\xi<x_1$.

 \end{enumerate}

[\textit{Hint:} Think Wronskian.]

\end{enumerate}
\tikz[overlay,remember picture]{\draw[red]
  (bl) rectangle
  (br);}
\end{document}

答案1

根据我的回答如何在保存框中添加列表和类似内容?,我将问题放在一个临时的 vbox 中,然后将其包含在一个中\fbox,并适当考虑缩进。

我在这里将这个过程定义为一个宏,\boxitem{}

\def\boxitem#1{\setbox0=\vbox{#1}{\centering\makebox[0pt]{%
  \fboxrule=2pt\color{red}\fbox{\hspace{\leftmargini}\color{black}\box0}}\par}}

然后在enumerateas中使用它\boxitem{\item[]...}。注意:\boxitem已修​​订,使其对后续空行不敏感。

\documentclass{article}    
\usepackage{amsthm, amssymb, amsfonts, amsmath, xcolor}% ADDED xcolor
\def\boxitem#1{\setbox0=\vbox{#1}{\centering\makebox[0pt]{%
  \fboxrule=2pt\color{red}\fbox{\hspace{\leftmargini}\color{black}\box0}}\par}}
    \begin{document}
    \begin{enumerate}
\boxitem{% THIS LINE ADDED
    \item[1.]
    Consider the initial value problem 
    \[
     \frac{dy}{dx} = 1- (y-x)^2, \qquad y=0 \,\, \text{at} \,\, x=0
    \]
    \begin{enumerate}
     \item[(a)] Find a solution to the problem.
     \item[(b)] Regardless of (a), is the solution unique?
     \item[(c)] Write down the Picard iteration scheme for this ODE and find some $r>0$ for which it converges $|x|<r$.
     \item[(d)] Find some $R>0$ such that the Picard iterates \textit{diverge} for $|x|>R$. 
    \end{enumerate}
}% THIS LINE ADDED
    \item[1a.]
       $\phi(x) = x$ is a solution, since $$\phi'(x) = 1 = 1 - (x-x)^2.$$
    \item[1b.]
       Note that the function $1-(y-x)^2$ is $C^{\infty}$ in both $x$ and $y$, and therefore given $x_0$, the function is locally Lipschitz in $y$, uniformly with respect to $x$ for $x$ in a neighborhood of $x_0$. Therefore such a solution is unique.
     \end{enumerate}
     \end{document}

在此处输入图片描述

后记:根据我与评论中的 OP 的交流,我只想补充一点,如果有人想在我的 之前和之后添加一个固定的垂直空间\fbox, 的定义\boxitem可以定义如下,其中3ex添加了 的空间,作为示例。

\def\boxitem#1{\vspace{3ex}\setbox0=\vbox{#1}{\centering\makebox[0pt]{%
  \fboxrule=2pt\color{red}\fbox{\hspace{\leftmargini}\color{black}\box0}}\vspace{3ex}\par}}

答案2

正如评论中提到的,您也可以使用tcolorbox 包来创建框。在我的示例代码中,我采用了enumitemA.Ellett 的包建议。

代码使用了您的示例三次:无框、有框,最后有从一页分解到下一页的框。

框的颜色、线宽、弧度等都可以调整。

\documentclass{article}

\usepackage{enumitem}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage[skins,breakable]{tcolorbox}

\newtcolorbox{mybox}[1][]{enhanced jigsaw,breakable,pad at break=1mm,
  oversize,left=8mm,interior hidden,colframe=red,nobeforeafter=,#1}

\begin{document}

\begin{enumerate}[label=\arabic*.]
\item
Consider the initial value problem
\[
  \frac{dy}{dx} = 1- (y-x)^2, \qquad y=0 \,\, \text{at} \,\, x=0
\]
  \begin{enumerate}[label=(\alph*)]
   \item Find a solution to the problem.\label{finding a solution}
   \item Regardless of \ref{finding a solution}, is the solution unique?
   \item Write down the Picard iteration scheme for this ODE and find some $r>0$ for which it converges $|x|<r$.
   \item Find some $R>0$ such that the Picard iterates \textit{diverge} for $|x|>R$.
  \end{enumerate}
\item Something not boxed
\item Also not boxed.
\end{enumerate}

\lipsum[2]

\begin{enumerate}[label=\arabic*.]
\begin{mybox}
\item Consider the initial value problem
\[
  \frac{dy}{dx} = 1- (y-x)^2, \qquad y=0 \,\, \text{at} \,\, x=0
\]
  \begin{enumerate}[label=(\alph*)]
   \item Find a solution to the problem.\label{finding a solution}
   \item Regardless of \ref{finding a solution}, is the solution unique?
   \item Write down the Picard iteration scheme for this ODE and find some $r>0$ for which it converges $|x|<r$.
   \item Find some $R>0$ such that the Picard iterates \textit{diverge} for $|x|>R$.
  \end{enumerate}
\end{mybox}
\item Something not boxed
\item Also not boxed.
\end{enumerate}

\begin{enumerate}[label=\arabic*.]
\begin{mybox}
\item Consider the initial value problem
\[
  \frac{dy}{dx} = 1- (y-x)^2, \qquad y=0 \,\, \text{at} \,\, x=0
\]
  \begin{enumerate}[label=(\alph*)]
   \item Find a solution to the problem.\label{finding a solution}
   \item Regardless of \ref{finding a solution}, is the solution unique?
   \item Write down the Picard iteration scheme for this ODE and find some $r>0$ for which it converges $|x|<r$.
   \item Find some $R>0$ such that the Picard iterates \textit{diverge} for $|x|>R$.
  \end{enumerate}
\end{mybox}
\item Something not boxed
\item Also not boxed.
\end{enumerate}

\end{document}

在此处输入图片描述

在此处输入图片描述

答案3

这是一个可行的解决方案,将第二个\tikzmark{br}移到枚举环境内以避免多余的空白。同时将相对距离调整为 5em 以覆盖整个文本。

在此处输入图片描述

代码

\documentclass{article}

\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{calc,shapes}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\begin{document}
\begin{enumerate}
\item[\tikzmark{bl} 1.]
Consider the initial value problem 
\[
 \frac{dy}{dx} = 1- (y-x)^2, \qquad y=0 \,\, \text{at} \,\, x=0
\]
\begin{enumerate}
 \item[(a)] Find a solution to the problem.
 \item[(b)] Regardless of (a), is the solution unique?
 \item[(c)] Write down the Picard iteration scheme for this ODE and find some $r>0$ for which it converges $|x|<r$.
 \item[(d)] Find some $R>0$ such that the Picard iterates \textit{diverge} for $|x|>R$. \tikzmark{br}
\end{enumerate}

\item[2.] Something not boxed
\item[3.] Also not boxed.
\end{enumerate}
\tikz[overlay,remember picture]{\draw[red]
  ($(bl)+(-0.2em,0.9em)$) rectangle
  ($(br)+(5em,-0.3em)$);}
\end{document}

答案4

我会做出一些改变:

  1. 我将使用该enumitem包来方便地格式化您的枚举环境的标签。
  2. 我将使用一\label/\ref对来引用先前的标签

这是为你的解决方案框使用tikz和一个\vadjust

\documentclass{article}
\usepackage{tikz}
\usepackage{enumitem}%%[inline]
\usepackage{amsmath}
\usetikzlibrary{calc,shapes}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\begin{document}
\begin{enumerate}[label=\arabic*.]
\item
\leavevmode
\strut
\vadjust{%%
  \noindent
  \raisebox{\dimexpr\dp\strutbox+\ht\strutbox+1ex}[0pt][0pt]{\tikzmark{bl}}}%%
Consider the initial value problem 
\[
  \frac{dy}{dx} = 1- (y-x)^2, \qquad y=0 \,\, \text{at} \,\, x=0
\]
  \begin{enumerate}[label=(\alph*)]
   \item Find a solution to the problem.\label{finding a solution}
   \item Regardless of \ref{finding a solution}, is the solution unique?
   \item Write down the Picard iteration scheme for this ODE and find some $r>0$ for which it converges $|x|<r$.
   \item Find some $R>0$ such that the Picard iterates \textit{diverge} for $|x|>R$. 
  \end{enumerate}

\leavevmode
\vadjust{%
  \noindent
  \hspace*{\dimexpr\textwidth+1ex}\tikzmark{br}}%%
\item Something not boxed
\item Also not boxed.
\end{enumerate}
\tikz[overlay,remember picture]{\draw[red]
  (bl) rectangle
  (br);}
\end{document}

在此处输入图片描述

此外,我不会使用该enumerate环境对家庭作业问题进行编号。我会创建自己的计数器和命令来按照以下方式执行此操作:

\newcounter{myproblemcnt}
\newcommand\problem{\par\refstepcounter{myproblemcnt}%%
  \noindent
  \textbf{\arabic{myproblemcnt}.}\hspace*{0.25em}}

相关内容