TransWikia.com

My row vector runs off the page in an `align*` environment

TeX - LaTeX Asked on April 16, 2021

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
newcommandmybox[1]{parbox[t]{0.75textwidth}{
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

2 Answers

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

Correct answer by campa on April 16, 2021

With use of the package linegoal:

documentclass{article}
%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%
usepackage{amsmath}
usepackage{linegoal}

begin{document}
    [
begin{aligned}
mathbf{y^*}
    & = (x_1,dots,x_{50}) 
    & = parbox[t]{0.8linegoal}{
        (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)

Answered by Zarko on April 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP