我正在尝试格式化一个包含 50 列的行向量,以便它保留在单个页面上(可能分布在多行上)。该向量位于环境中align*
。我的代码如下所示
\begin{align*}
\mathbf{y^*}&=\left(x_1,\dots,x_{50}\right) \\
&=\left(7, 1, 1, 1, 0, 1, 7, 8, 40, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 11, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 9, 1, 0, 1, 0, 1, 0, 1, 1, 2, 0, 1 \right)
\end{align*}
如何格式化才能使矢量不超出页面范围。
编辑
\usepackage{amsmath}
\usepackage{setspace} % for "\setstretch" macro
\newcommand\mybox[1]{\parbox[t]{0.75\textwidth}{
\setstretch{1.33}\raggedright$\displaystyle #1$}}
\begin{align*}
\mathbf{y^*}&=(x_1,\dots,x_{50}) \\
&=\mybox{(7, 1, 1, 1, 0, 1, 7, 8, 40, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0,
1, 0, 1, 1, 11, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 9, 1, 0, 1, 0, 1, 0, 1, 1,
2, 0, 1)}
\end{align*}
另一个想法
\begin{equation*}
\begin{split}
\mathbf{x^*}=&\left(x_1,\dots,x_{50}\right) \\
=&(7, 1, 1, 1, 0, 1, 7, 8, 40, 1, \\ & 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, \\
& 1, 0, 1, 0, 1, 1, 11, 0, 1, 0, \\ & 1, 1, 0, 1, 0, 1, 1, 0, 9, 1, \\ & 0,
1, 0, 1, 0, 1, 1, 2, 0, 1)
\end{split}
\end{equation*}
答案1
一些想法
\documentclass{article}
\usepackage{lipsum,amsmath}
\begin{document}
\lipsum*[75]
\begin{multline*}
\begin{aligned}
\mathbf{y^*}
&= (x_1,\dots,x_{50}) \\
&= (7, 1, 1, 1, 0, 1, 7, 8, 40, 1,
\end{aligned}
\\
0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 11, 0, 1, 0,
\\
1, 1, 0, 1, 0, 1, 1, 0, 9, 1, 0, 1, 0, 1, 0, 1, 1, 2, 0, 1)
\end{multline*}
\lipsum*[75]
\begin{align*}
\mathbf{y^*}
& = (x_1,\dots,x_{50}) \\
&= \begin{aligned}[t]
(& 7, 1, 1, 1, 0, 1, 7, 8, 40, 1, \\
& 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, \\
& 1, 0, 1, 0, 1, 1, 11, 0, 1, 0, \\
& 1, 1, 0, 1, 0, 1, 1, 0, 9, 1,\\
& 0, 1, 0, 1, 0, 1, 1, 2, 0, 1)
\end{aligned}
\end{align*}
\lipsum*[75]
\begin{align*}
\mathbf{y^*}
&= (x_1,\dots,x_{50}) \\
&= (
\begin{array}[t]{@{\:}c*{9}{@{\;,\;}c}}
7 & 1 & 1 & 1 & 0 & 1 & 7 & 8 & 40 & 1 \\
0 & 0 & 1 & 0 & 1 & 0 & 0 & 1 & 0 & 1 \\
1 & 0 & 1 & 0 & 1 & 1 & 11 & 0 & 1 & 0 \\
1 & 1 & 0 & 1 & 0 & 1 & 1 & 0 & 9 & 1 \\
0 & 1 & 0 & 1 & 0 & 1 & 1 & 2 & 0 & 1 \rlap{$\:)$}
\end{array}
\end{align*}
\end{document}
答案2
使用该包\linegoal
:
\documentclass{article}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{amsmath}
\usepackage{linegoal}
\begin{document}
\[
\begin{aligned}
\mathbf{y^*}
& = (x_1,\dots,x_{50}) \\
& = \parbox[t]{0.8\linegoal}{
(7, 1, 1, 1, 0, 1, 7, 8, 40, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0,
1, 1, 11, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 9, 1, 0, 1, 0, 1, 0, 1, 1, 2,
0, 1)
}
\end{aligned}
\]
\end{document}
最终结果需要编译两次:
(红线表示页面布局)