答案1
一个可能的解决方案:只需创建一个表格单元格:
\documentclass{article}
\usepackage[table,xcdraw]{xcolor}
\usepackage{lipsum}
\usepackage{amssymb}
\usepackage{enumitem}
\begin{document}
\begin{table}[]
\renewcommand{\arraystretch}{1.25}
\centering
%\caption{}
\label{tab:my-table}
\begin{tabular}{|
>{\columncolor[HTML]{EFEFEF}}p{0.9\textwidth} |}
\hline
\textbf{The Gradient Method}\\
\\
\textbf{Input:} $\epsilon>0$\\
\textbf{Initialization:} Pick $x_0 \in \mathbb{R}^{n}$ arbitrarily.\\
\textbf{General step:} For any $k=0,1,2...$ execute the following steps:
\begin{enumerate}[label=(\alph*)]
\item Pick a stepsize $t_k$ by a line search procedure on the function.
\begin{center}$g(t)=f(x_k-t\triangledown f(x_k))$\end{center}
\item Set $x_{k+1}=x_k+t_k\triangledown f(x_k)$
\item If $\parallel \triangledown f(x_{k+1}) \parallel \leq \epsilon$, then STOP and $x_{k+1}$ is the output.
\end{enumerate}
\\ \hline
\end{tabular}
\end{table}
\end{document}
答案2
这里有一个 tcolorbox 解决方案:
% https://tex.stackexchange.com/questions/581381/how-to-create-a-rectangular-framework
\documentclass{article}
\usepackage[table,xcdraw]{xcolor}
\usepackage{lipsum}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\begin{document}
\begin{table}[]
\renewcommand{\arraystretch}{1.25}
\centering
% \caption{}
\label{tab:my-table}
\begin{tabular}{|
>{\columncolor[HTML]{EFEFEF}}p{0.9\textwidth} |}
\hline
\textbf{The Gradient Method}\\
\\
\textbf{Input:} $\epsilon>0$\\
\textbf{Initialization:} Pick $x_0 \in \mathbb{R}^{n}$ arbitrarily.\\
\textbf{General step:} For any $k=0,1,2...$ execute the following steps:
\begin{enumerate}[label=(\alph*)]
\item Pick a stepsize $t_k$ by a line search procedure on the function.
\begin{center}$g(t)=f(x_k-t\triangledown f(x_k))$\end{center}
\item Set $x_{k+1}=x_k+t_k\triangledown f(x_k)$
\item If $\parallel \triangledown f(x_{k+1}) \parallel \leq \epsilon$, then STOP and $x_{k+1}$ is the output.
\end{enumerate}
\\ \hline
\end{tabular}
\end{table}
\begin{tcolorbox}[enhanced, title=The Gradient Method,%
colbacktitle=black!20, coltitle=black, colframe=black, sharp corners,%
colback=black!10, boxrule=.5pt, titlerule=0pt,%
]
\textbf{Input:} $\epsilon>0$\\
\textbf{Initialization:} Pick $x_0 \in \mathbb{R}^{n}$ arbitrarily.\\
\textbf{General step:} For any $k=0,1,2\ldots$ execute the following steps:
\begin{enumerate}[label= (\alph*)]
\item Pick a stepsize $t_k$ by a line search procedure on the function.
\begin{center}$g(t)=f(x_k-t\triangledown f(x_k))$\end{center}
\item Set $x_{k+1}=x_k+t_k\triangledown f(x_k)$
\item If $\parallel \triangledown f(x_{k+1}) \parallel \leq \epsilon$, then STOP and $x_{k+1}$ is the output.
\end{enumerate}
\end{tcolorbox}
\end{document}