答案1
这是一个相当原始的版本tabularx
。
\documentclass{article}
\usepackage{tabularx}
\usepackage{blindtext}
\newcommand{\myboxstuff}[3]{%
\noindent%
\begin{tabularx}{\linewidth}{|llX|}
\hline
\multicolumn{3}{|X|}{\scshape #1} \tabularnewline
& & \tabularnewline
\textit{Instance:} & & #2 \tabularnewline
& & \tabularnewline
\textit{Task:} & & #3 \tabularnewline
\hline
\end{tabularx}%
}
\begin{document}
\myboxstuff{Linear Programming}{Some Matrix\dots}{\blindtext}
\end{document}
答案2
这里有两个解决方案,分为两种变体:一种也基于tabularx
,另一种基于framed
并enumitem
定义一个programdescr
可以跨页中断的环境。定义了两个命令:\instance
和task
。
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry} \usepackage{MinionPro}
\usepackage{tabularx, makecell}
\setcellgapes{4pt}
\usepackage{enumitem, framed}
\usepackage{etoolbox, xcolor} %
\newenvironment{programdescr}[1][]{\FrameSep=6pt\framed%
\setlist[description, 1]{font=\normalfont\itshape, , wide = 0pt, labelwidth=1.6cm, leftmargin=\labelwidth, itemindent=0pt, style=sameline}%
\newcommand\instance{\item[Instance:]}\newcommand\task{\item[Task:]}%
\noindent\textsc{#1}\vspace{-0.5\topsep}\description}%
{\enddescription\vspace{-\topsep}\endframed}%
\begin{document}
\makegapedcells
\noindent \begin{tabularx}{\linewidth}{|>{\itshape}p{1.2cm} >{\arraybackslash}X |}
\hline
\multicolumn{2}{|>{\scshape}l|}{Linear Programming} \\ Instance: & A matrix $ A \in \mathbf R^{m \times n} $ and column vectors $ b \in \mathbf R^m $, $ c \in \mathbf R^n$. \\%
Task: & Find a column vector $ b \in \mathbf R^n $ such that $ Ax \le b $ and $ c^\top x $ is maximum, decide that $ \{x \in \mathbf R^n\:\colon\: Ax \le b \} $ is empty, or decide that for all $ \alpha \in \mathbf R $ there is an $ x \in \mathbf R^n$ with $ Ax \le b$ and $ c^\top x > \alpha $. \\%
\hline
\end{tabularx}
\vskip1cm
\noindent \begin{tabularx}{\linewidth}{|>{\itshape\raggedleft}p{1.2cm}>{\arraybackslash}X |}
\hline
\multicolumn{2}{|>{\scshape}l|}{Linear Programming} \\ Instance: & A matrix $ A \in \mathbf R^{m \times n} $ and column vectors $ b \in \mathbf R^m $, $ c \in \mathbf R^n$. \\%
Task: & Find a column vector $ b \in \mathbf R^n $ such that $ Ax \le b $ and $ c^\top x $ is maximum, decide that $ \{x \in \mathbf R^n\:\colon\: Ax \le b \} $ is empty, or decide that for all $ \alpha \in \mathbf R $ there is an $ x \in \mathbf R^n$ with $ Ax \le b$ and $ c^\top x > \alpha $. \\%
\hline
\end{tabularx}
\FrameSep=6pt\begin{framed}
\noindent\textsc{Linear Programming}\vspace{-0.5\topsep}
\begin{description}[font=\normalfont\itshape, labelwidth=1.6cm, leftmargin=\labelwidth, itemindent=0pt, align=right]
\item[Instance:]
A matrix $ A \in \mathbf R^{m \times n} $ and column vectors $ b \in \mathbf R^m $, $ c \in \mathbf R^n$.
\item[Task: ] Find a column vector $ b \in \mathbf R^n $ such that $ Ax \le b $ and $ c^\top x $ is maximum, decide that $ \{x \in \mathbf R^n\:\colon\: Ax \le b \} $ is empty, or decide that for all $ \alpha \in \mathbf R $ there is an $ x \in \mathbf R^n$ with $ Ax \le b$ and $ c^\top x > \alpha $.
\end{description}
\vspace{-\topsep}
\end{framed}
\begin{programdescr}[Linear Programming]
\instance
A matrix $ A \in \mathbf R^{m \times n} $ and column vectors $ b \in \mathbf R^m $, $ c \in \mathbf R^n$.
\task Find a column vector $ b \in \mathbf R^n $ such that $ Ax \le b $ and $ c^\top x $ is maximum, decide that $ \{x \in \mathbf R^n\:\colon\: Ax \le b \} $ is empty, or decide that for all $ \alpha \in \mathbf R $ there is an $ x \in \mathbf R^n$ with $ Ax \le b$ and $ c^\top x > \alpha $.
\end{programdescr}
\end{document}