2

I am trying to format a row vector with fifty columns such that it remains on a single page (perhaps over multiples lines). The vector is in an align* environment. My code is shown below

\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*}

How can this be formatted such that the vector does not run off the page.

Edit

\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*}

Another idea

\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*}

enter image description here

M B
  • 152
  • Maybe this can help: https://tex.stackexchange.com/a/410942/10898 – azetina Nov 18 '20 at 05:47
  • @azetina I tried to follow their method. I used the packages in the example and altered my column vector to \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)}. However, the vector still runs off the page. – M B Nov 18 '20 at 07:22
  • Can you update your question so that we can see how you implemented the technique? – azetina Nov 18 '20 at 07:25
  • @azetina I have done so. – M B Nov 18 '20 at 07:28
  • Maybe tedious, but putting the data in a sub array would be easier in this case. – azetina Nov 18 '20 at 07:34
  • 1
    Try this: \documentclass[letterpaper]{article} \usepackage{amsmath,array} \begin{document} \begin{align} \mathbf{y^} &=\left(x_1,\dots,x_{50}\right) \ &= \begin{array}[t]{@{}r@{}{9}{@{\ }c<{,}}@{\ }c@{}l} (& 1 & 1& 1& 1& 1& 1& 1& 1& 1& 1,& \ & 1 & 1& 1& 1& 1& 1& 1& 1& 1& 1\phantom{,}&) \ \end{array} \end{align} \end{document} – azetina Nov 18 '20 at 07:56

2 Answers2

4

With use of the package \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}

For final result need to be compiled twice:

enter image description here

(red lines indicate page layout)

Zarko
  • 296,517
3

A couple of ideas

\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}

enter image description here

campa
  • 31,130
  • I tried using the \equation* environment (I have placed the code in my post). Though, I don't like the look of it. It would look better if the first entries in subsequent rows vertically aligned with the first entry of the first row. – M B Nov 18 '20 at 07:56
  • @MB I've added an alternative. – campa Nov 18 '20 at 08:06
  • This is perfect. Obviously I can ignore the lipsum*[4] and only take that within the align* environment, right? – M B Nov 18 '20 at 08:15
  • @MB Of course, the \lipsum is just for the dummy text. I have added yet another version. – campa Nov 18 '20 at 08:17