我有以下代码:
\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{classicthesis}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage{amsmath,mathtools}
\usepackage{amsfonts}
\usepackage{color}
\usepackage{url}
\usepackage{enumitem}
\usepackage{multicol}
\usepackage{tabu}
\usepackage{amsthm}
\usepackage{fourier-orns}
\usepackage{framed}
\usepackage{tcolorbox}
\usepackage[toc,page]{appendix}
\usepackage[all]{xy}
\begin{document}
\begin{enumerate}
\item For the function $y=x,$ find the derivative, $y'.$
\[y'=\lim_{h\to 0}\frac{(x+h)-x}{h}=\lim_{h\to 0}\frac{h}{h}=\lim_{h\to 0}1=1.\]
\item For the function $y=x^2,$ find the derivative, $y'.$
\begin{align*}
y'=\lim_{h\to 0}\frac{(x+h)^2-x^2}{h}&=\lim_{h\to 0}\frac{x^2+2xh+h^2-x^2}{h}\\
&=\lim_{h\to 0}\frac{2xh+h^2}{h}=\lim_{h\to 0}(2x+h)=2x.
\end{align*}
\begin{center}
\begin{framed}
For the next two examples, we will use the angle sum formula for sine, which is
\[\sin(\alpha+\beta)=\sin\alpha\cos\beta+\cos\alpha\sin\beta.\]
\end{framed}
\end{center}
\item For the function $y=\sin x,$ find the derivative, $y'.$
\begin{align*}
y'=\lim_{h\to 0}\frac{\sin (x+h)-\sin x}{h}&=\lim_{h\to 0}\frac{\sin x\cos h+\cos x\sin h-\sin x}{h}\\
&=\lim_{h\to 0}\frac{\sin x(\cos h-1)+\cos x\sin h}{h}\\
&=\left[\lim_{h\to 0}(\sin x)\left(\frac{\cos h-1}{h}\right)\right]\left[\lim_{h\to 0}(\cos x)\left(\frac{\sin h}{h}\right)\right]\\
&=(\sin x)\cdot 0+(\cos x)\cdot 1\\
&=\cos x,
\end{align*}
where we have used $\displaystyle\lim_{h\to 0}\frac{\sin h}{h}=1$ and $\displaystyle\lim_{h\to 0}\frac{\cos h-1}{h}=0$ from section (1.3).
\item Find $\dfrac{d}{dx}\tan x.$
\begin{align*}
\dfrac{d}{dx}\tan x=\displaystyle\lim_{h\to 0}\dfrac{\tan(x+h)-\tan x}{h}&=\displaystyle\lim_{h\to 0}\left(\dfrac{\sin(x+h)}{h\cos(x+h)}-\dfrac{\sin x}{h\cos x}\right)\\
&=\displaystyle\lim_{h\to 0}\left(\dfrac{\sin(x+h)\cos x-\cos(x+h)\sin x}{h\cos(x+h)\cos x}\right)\\
&=\displaystyle\lim_{h\to 0}\left(\dfrac{\sin[(x+h)-x]}{h\cos(x+h)\cos x}\right)\\
&=\displaystyle\lim_{h\to 0}\left[\left(\dfrac{\sin h}{h}\right)\left(\dfrac{1}{\cos(x+h)\cos x}\right)\right]\\
&=\dfrac{1}{\cos^2(x)}=\sec^2 x.
\end{align*}
\end{enumerate}
\end{document}
我一直收到错误“出了点问题——可能缺少 \item“
如何解决这个问题?
答案1
您需要\leavevmode
在framed
环境之前;但是,我想建议您使用tcolorbox
包(您已经加载了)的另一种方法。下面是原始示例framed
,然后是具有tcolorbox
定义宽度的(\makebox
用于将框相对于居中\textwidth
):
\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{classicthesis}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage{amsmath,mathtools}
\usepackage{amsfonts}
\usepackage{color}
\usepackage{url}
\usepackage{enumitem}
\usepackage{multicol}
\usepackage{tabu}
\usepackage{amsthm}
\usepackage{fourier-orns}
\usepackage{framed}
\usepackage[many]{tcolorbox}
\usepackage[toc,page]{appendix}
\usepackage[all]{xy}
\usepackage[margin=2cm,showframe]{geometry}
\begin{document}
\begin{enumerate}
\item For the function $y=x,$ find the derivative, $y'.$
\[y'=\lim_{h\to 0}\frac{(x+h)-x}{h}=\lim_{h\to 0}\frac{h}{h}=\lim_{h\to 0}1=1.\]
\item For the function $y=x^2,$ find the derivative, $y'.$
\begin{align*}
y'=\lim_{h\to 0}\frac{(x+h)^2-x^2}{h}&=\lim_{h\to 0}\frac{x^2+2xh+h^2-x^2}{h}\\
&=\lim_{h\to 0}\frac{2xh+h^2}{h}=\lim_{h\to 0}(2x+h)=2x.
\end{align*}
\begin{center}\leavevmode
\begin{framed}
For the next two examples, we will use the angle sum formula for sine, which is
\[\sin(\alpha+\beta)=\sin\alpha\cos\beta+\cos\alpha\sin\beta.\]
\end{framed}
\end{center}
\makebox[\linewidth]{%
\begin{tcolorbox}[arc=0pt,outer arc=0pt,colback=white,width=.6\textwidth]
For the next two examples, we will use the angle sum formula for sine, which is
\[\sin(\alpha+\beta)=\sin\alpha\cos\beta+\cos\alpha\sin\beta.\]
\end{tcolorbox}}
\item For the function $y=\sin x,$ find the derivative, $y'.$
\begin{align*}
y'=\lim_{h\to 0}\frac{\sin (x+h)-\sin x}{h}&=\lim_{h\to 0}\frac{\sin x\cos h+\cos x\sin h-\sin x}{h}\\
&=\lim_{h\to 0}\frac{\sin x(\cos h-1)+\cos x\sin h}{h}\\
&=\left[\lim_{h\to 0}(\sin x)\left(\frac{\cos h-1}{h}\right)\right]\left[\lim_{h\to 0}(\cos x)\left(\frac{\sin h}{h}\right)\right]\\
&=(\sin x)\cdot 0+(\cos x)\cdot 1\\
&=\cos x,
\end{align*}
where we have used $\displaystyle\lim_{h\to 0}\frac{\sin h}{h}=1$ and $\displaystyle\lim_{h\to 0}\frac{\cos h-1}{h}=0$ from section (1.3).
\item Find $\dfrac{d}{dx}\tan x.$
\begin{align*}
\dfrac{d}{dx}\tan x=\displaystyle\lim_{h\to 0}\dfrac{\tan(x+h)-\tan x}{h}&=\displaystyle\lim_{h\to 0}\left(\dfrac{\sin(x+h)}{h\cos(x+h)}-\dfrac{\sin x}{h\cos x}\right)\\
&=\displaystyle\lim_{h\to 0}\left(\dfrac{\sin(x+h)\cos x-\cos(x+h)\sin x}{h\cos(x+h)\cos x}\right)\\
&=\displaystyle\lim_{h\to 0}\left(\dfrac{\sin[(x+h)-x]}{h\cos(x+h)\cos x}\right)\\
&=\displaystyle\lim_{h\to 0}\left[\left(\dfrac{\sin h}{h}\right)\left(\dfrac{1}{\cos(x+h)\cos x}\right)\right]\\
&=\dfrac{1}{\cos^2(x)}=\sec^2 x.
\end{align*}
\end{enumerate}
\end{document}
结果:
我用了
\usepackage[margin=2cm,showframe]{geometry}
示例中只是提供了页面布局的视觉指南。
答案2
另一种选择是使用minipage
代码中所示的环境
\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{classicthesis}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage{amsmath,mathtools}
\usepackage{amsfonts}
\usepackage{color}
\usepackage{url}
\usepackage{enumitem}
\usepackage{multicol}
\usepackage{tabu}
\usepackage{amsthm}
\usepackage{fourier-orns}
\usepackage{framed}
\usepackage{tcolorbox}
\usepackage[toc,page]{appendix}
\usepackage[all]{xy}
\begin{document}
\begin{enumerate}
\item For the function $y=x,$ find the derivative, $y'.$
\[y'=\lim_{h\to 0}\frac{(x+h)-x}{h}=\lim_{h\to 0}\frac{h}{h}=\lim_{h\to 0}1=1.\]
\item For the function $y=x^2,$ find the derivative, $y'.$
\begin{align*}
y'=\lim_{h\to 0}\frac{(x+h)^2-x^2}{h}&=\lim_{h\to 0}\frac{x^2+2xh+h^2-x^2}{h}\\
&=\lim_{h\to 0}\frac{2xh+h^2}{h}=\lim_{h\to 0}(2x+h)=2x.
\end{align*}
\begin{minipage}[c]{0.75\textwidth}
\begin{framed}
For the next two examples, we will use the angle sum formula for sine, which is
\[\sin(\alpha+\beta)=\sin\alpha \cos\beta+\cos\alpha \sin\beta.\]
\end{framed}
\end{minipage}
\item For the function $y=\sin x,$ find the derivative, $y'.$
\begin{align*}
y'=\lim_{h\to 0}\frac{\sin (x+h)-\sin x}{h}&=\lim_{h\to 0}\frac{\sin x\cos h+\cos x\sin h-\sin x}{h}\\
&=\lim_{h\to 0}\frac{\sin x(\cos h-1)+\cos x\sin h}{h}\\
&=\left[\lim_{h\to 0}(\sin x)\left(\frac{\cos h-1}{h}\right)\right]\left[\lim_{h\to 0}(\cos x)\left(\frac{\sin h}{h}\right)\right]\\
&=(\sin x)\cdot 0+(\cos x)\cdot 1\\
&=\cos x,
\end{align*}
where we have used $\displaystyle\lim_{h\to 0}\frac{\sin h}{h}=1$ and $\displaystyle\lim_{h\to 0}\frac{\cos h-1}{h}=0$ from section (1.3).
\item Find $\dfrac{d}{dx}\tan x.$
\begin{align*}
\dfrac{d}{dx}\tan x=\displaystyle\lim_{h\to 0}\dfrac{\tan(x+h)-\tan x}{h}&=\displaystyle\lim_{h\to 0}\left(\dfrac{\sin(x+h)}{h\cos(x+h)}-\dfrac{\sin x}{h\cos x}\right)\\
&=\displaystyle\lim_{h\to 0}\left(\dfrac{\sin(x+h)\cos x-\cos(x+h)\sin x}{h\cos(x+h)\cos x}\right)\\
&=\displaystyle\lim_{h\to 0}\left(\dfrac{\sin[(x+h)-x]}{h\cos(x+h)\cos x}\right)\\
&=\displaystyle\lim_{h\to 0}\left[\left(\dfrac{\sin h}{h}\right)\left(\dfrac{1}{\cos(x+h)\cos x}\right)\right]\\
&=\dfrac{1}{\cos^2(x)}=\sec^2 x.
\end{align*}
\end{enumerate}
\end{document}