Multicolumn: justify left and fill unused space from the left. (Odd pages.)












1















Esteemed community, I have a two column document layout, and am aware that normally I can choose between




  1. justifying text to the left, which fills unused space from the right, and

  2. justifying text to the right, which fills unused space from the right.


How can I get alignment that justifies text to the left, but places the entire box of text as far to the right in the column as possible according to the longest line, thus filling unused space from the left?



The solution should affect whole columns on odd-numbered pages (should be definable centrally), and I don't know the width of the text beforehand, this may be different for every column.



Many thanks for your input.



Requited behaviour on odd page










share|improve this question

























  • Hi Ranavir, providing a minimum example code to work with could help people better understand your problem and give you a better answer :)

    – Superuser27
    Mar 8 at 10:43
















1















Esteemed community, I have a two column document layout, and am aware that normally I can choose between




  1. justifying text to the left, which fills unused space from the right, and

  2. justifying text to the right, which fills unused space from the right.


How can I get alignment that justifies text to the left, but places the entire box of text as far to the right in the column as possible according to the longest line, thus filling unused space from the left?



The solution should affect whole columns on odd-numbered pages (should be definable centrally), and I don't know the width of the text beforehand, this may be different for every column.



Many thanks for your input.



Requited behaviour on odd page










share|improve this question

























  • Hi Ranavir, providing a minimum example code to work with could help people better understand your problem and give you a better answer :)

    – Superuser27
    Mar 8 at 10:43














1












1








1








Esteemed community, I have a two column document layout, and am aware that normally I can choose between




  1. justifying text to the left, which fills unused space from the right, and

  2. justifying text to the right, which fills unused space from the right.


How can I get alignment that justifies text to the left, but places the entire box of text as far to the right in the column as possible according to the longest line, thus filling unused space from the left?



The solution should affect whole columns on odd-numbered pages (should be definable centrally), and I don't know the width of the text beforehand, this may be different for every column.



Many thanks for your input.



Requited behaviour on odd page










share|improve this question
















Esteemed community, I have a two column document layout, and am aware that normally I can choose between




  1. justifying text to the left, which fills unused space from the right, and

  2. justifying text to the right, which fills unused space from the right.


How can I get alignment that justifies text to the left, but places the entire box of text as far to the right in the column as possible according to the longest line, thus filling unused space from the left?



The solution should affect whole columns on odd-numbered pages (should be definable centrally), and I don't know the width of the text beforehand, this may be different for every column.



Many thanks for your input.



Requited behaviour on odd page







horizontal-alignment multicolumn alignment layout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 11:41







ranavir

















asked Mar 8 at 10:42









ranavirranavir

84




84













  • Hi Ranavir, providing a minimum example code to work with could help people better understand your problem and give you a better answer :)

    – Superuser27
    Mar 8 at 10:43



















  • Hi Ranavir, providing a minimum example code to work with could help people better understand your problem and give you a better answer :)

    – Superuser27
    Mar 8 at 10:43

















Hi Ranavir, providing a minimum example code to work with could help people better understand your problem and give you a better answer :)

– Superuser27
Mar 8 at 10:43





Hi Ranavir, providing a minimum example code to work with could help people better understand your problem and give you a better answer :)

– Superuser27
Mar 8 at 10:43










1 Answer
1






active

oldest

votes


















1














Click on the images to see it in a better resolution



Edit 1: Odd/even page check added



documentclass{article}
usepackage[showframe]{geometry}
usepackage{lipsum}
usepackage{array}
usepackage{varwidth}
usepackage{changepage}
strictpagecheck
defmaxwidth{13cm}
newcolumntype{M}{>{begin{varwidth}{maxwidth}}l<{end{varwidth}}}
newenvironment{myenvi}
{%
checkoddpage
ifoddpage
hfillbegin{tabular}{@{}M@{}}
fi
}
{%
checkoddpage
ifoddpage
end{tabular}hspace{-3.5pt}
fi
}

setlength{parskip}{1ex}
begin{document}
lipsum[1]

begin{myenvi}
Oh, this is what I want!

I really want some lines like this

And this line is a bit too long, so it will be broken to some lines blah blah. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines.
end{myenvi}

And some more normal lines

begin{myenvi}
This is a short text for testing whose total width is clearly less than 10cm.

And this is an even shorter text.
end{myenvi}

lipsum[2-6]

begin{myenvi}
This is the environment for check in an even page. It should be like normal text.

Yes, this is normal text!
end{myenvi}

lipsum[7]
end{document}


Page 1 (odd):



enter image description here



Page 2 (even):



enter image description here



Original answer



Define a new tabular column type and use hfill



documentclass{article}
usepackage{lipsum}
usepackage{array}
usepackage{varwidth}
newcolumntype{M}{>{begin{varwidth}{10cm}}l<{end{varwidth}}}

setlength{parskip}{1ex}
begin{document}
lipsum[1]

hfillbegin{tabular}{@{}M@{}}
Oh, this is what I want!

I really want some lines like this

And this line is a bit too long, so it will be broken to some lines blah blah. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines.
end{tabular}

lipsum[2]
end{document}


enter image description here






share|improve this answer


























  • Thanks, that's pretty cool, but to make the solution practical for my case, do you think there would there be a way to define this automatically for columns in odd pages only? Also, how can I affect the length of the space at which the long line will be broken?

    – ranavir
    Mar 8 at 11:33













  • @ranavir For the first question: This is only a hfill and an environment combined, so you can add this anywhere. If you want this on an odd page, add this on that page!

    – JouleV
    Mar 8 at 11:36











  • @ranavir For the second question: Look at the newcolumntype. You see a number 10cm. That is the width of the text. You can always change it, of course.

    – JouleV
    Mar 8 at 11:37











  • Ok, I get it. There are unfortunately two reasons why this is not practical. 1) I don't know the width number beforehand, I want it to be set to the longest line in the box. (Imagine this is e.g. a book of songs or poems with short lines.) 2) I don't know in advance which page is odd and which is even. The publication is sorted and rolling, so inserting a new page would mean I have to go and change all the subsequent pages manually.

    – ranavir
    Mar 8 at 11:40











  • @ranavir (1) Have you checked my code? 10cm is only the maximum width, not the width. Delete the And this line is a bit too long, so it ... and see what happens.

    – JouleV
    Mar 8 at 11:46











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478389%2fmulticolumn-justify-left-and-fill-unused-space-from-the-left-odd-pages%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Click on the images to see it in a better resolution



Edit 1: Odd/even page check added



documentclass{article}
usepackage[showframe]{geometry}
usepackage{lipsum}
usepackage{array}
usepackage{varwidth}
usepackage{changepage}
strictpagecheck
defmaxwidth{13cm}
newcolumntype{M}{>{begin{varwidth}{maxwidth}}l<{end{varwidth}}}
newenvironment{myenvi}
{%
checkoddpage
ifoddpage
hfillbegin{tabular}{@{}M@{}}
fi
}
{%
checkoddpage
ifoddpage
end{tabular}hspace{-3.5pt}
fi
}

setlength{parskip}{1ex}
begin{document}
lipsum[1]

begin{myenvi}
Oh, this is what I want!

I really want some lines like this

And this line is a bit too long, so it will be broken to some lines blah blah. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines.
end{myenvi}

And some more normal lines

begin{myenvi}
This is a short text for testing whose total width is clearly less than 10cm.

And this is an even shorter text.
end{myenvi}

lipsum[2-6]

begin{myenvi}
This is the environment for check in an even page. It should be like normal text.

Yes, this is normal text!
end{myenvi}

lipsum[7]
end{document}


Page 1 (odd):



enter image description here



Page 2 (even):



enter image description here



Original answer



Define a new tabular column type and use hfill



documentclass{article}
usepackage{lipsum}
usepackage{array}
usepackage{varwidth}
newcolumntype{M}{>{begin{varwidth}{10cm}}l<{end{varwidth}}}

setlength{parskip}{1ex}
begin{document}
lipsum[1]

hfillbegin{tabular}{@{}M@{}}
Oh, this is what I want!

I really want some lines like this

And this line is a bit too long, so it will be broken to some lines blah blah. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines.
end{tabular}

lipsum[2]
end{document}


enter image description here






share|improve this answer


























  • Thanks, that's pretty cool, but to make the solution practical for my case, do you think there would there be a way to define this automatically for columns in odd pages only? Also, how can I affect the length of the space at which the long line will be broken?

    – ranavir
    Mar 8 at 11:33













  • @ranavir For the first question: This is only a hfill and an environment combined, so you can add this anywhere. If you want this on an odd page, add this on that page!

    – JouleV
    Mar 8 at 11:36











  • @ranavir For the second question: Look at the newcolumntype. You see a number 10cm. That is the width of the text. You can always change it, of course.

    – JouleV
    Mar 8 at 11:37











  • Ok, I get it. There are unfortunately two reasons why this is not practical. 1) I don't know the width number beforehand, I want it to be set to the longest line in the box. (Imagine this is e.g. a book of songs or poems with short lines.) 2) I don't know in advance which page is odd and which is even. The publication is sorted and rolling, so inserting a new page would mean I have to go and change all the subsequent pages manually.

    – ranavir
    Mar 8 at 11:40











  • @ranavir (1) Have you checked my code? 10cm is only the maximum width, not the width. Delete the And this line is a bit too long, so it ... and see what happens.

    – JouleV
    Mar 8 at 11:46
















1














Click on the images to see it in a better resolution



Edit 1: Odd/even page check added



documentclass{article}
usepackage[showframe]{geometry}
usepackage{lipsum}
usepackage{array}
usepackage{varwidth}
usepackage{changepage}
strictpagecheck
defmaxwidth{13cm}
newcolumntype{M}{>{begin{varwidth}{maxwidth}}l<{end{varwidth}}}
newenvironment{myenvi}
{%
checkoddpage
ifoddpage
hfillbegin{tabular}{@{}M@{}}
fi
}
{%
checkoddpage
ifoddpage
end{tabular}hspace{-3.5pt}
fi
}

setlength{parskip}{1ex}
begin{document}
lipsum[1]

begin{myenvi}
Oh, this is what I want!

I really want some lines like this

And this line is a bit too long, so it will be broken to some lines blah blah. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines.
end{myenvi}

And some more normal lines

begin{myenvi}
This is a short text for testing whose total width is clearly less than 10cm.

And this is an even shorter text.
end{myenvi}

lipsum[2-6]

begin{myenvi}
This is the environment for check in an even page. It should be like normal text.

Yes, this is normal text!
end{myenvi}

lipsum[7]
end{document}


Page 1 (odd):



enter image description here



Page 2 (even):



enter image description here



Original answer



Define a new tabular column type and use hfill



documentclass{article}
usepackage{lipsum}
usepackage{array}
usepackage{varwidth}
newcolumntype{M}{>{begin{varwidth}{10cm}}l<{end{varwidth}}}

setlength{parskip}{1ex}
begin{document}
lipsum[1]

hfillbegin{tabular}{@{}M@{}}
Oh, this is what I want!

I really want some lines like this

And this line is a bit too long, so it will be broken to some lines blah blah. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines.
end{tabular}

lipsum[2]
end{document}


enter image description here






share|improve this answer


























  • Thanks, that's pretty cool, but to make the solution practical for my case, do you think there would there be a way to define this automatically for columns in odd pages only? Also, how can I affect the length of the space at which the long line will be broken?

    – ranavir
    Mar 8 at 11:33













  • @ranavir For the first question: This is only a hfill and an environment combined, so you can add this anywhere. If you want this on an odd page, add this on that page!

    – JouleV
    Mar 8 at 11:36











  • @ranavir For the second question: Look at the newcolumntype. You see a number 10cm. That is the width of the text. You can always change it, of course.

    – JouleV
    Mar 8 at 11:37











  • Ok, I get it. There are unfortunately two reasons why this is not practical. 1) I don't know the width number beforehand, I want it to be set to the longest line in the box. (Imagine this is e.g. a book of songs or poems with short lines.) 2) I don't know in advance which page is odd and which is even. The publication is sorted and rolling, so inserting a new page would mean I have to go and change all the subsequent pages manually.

    – ranavir
    Mar 8 at 11:40











  • @ranavir (1) Have you checked my code? 10cm is only the maximum width, not the width. Delete the And this line is a bit too long, so it ... and see what happens.

    – JouleV
    Mar 8 at 11:46














1












1








1







Click on the images to see it in a better resolution



Edit 1: Odd/even page check added



documentclass{article}
usepackage[showframe]{geometry}
usepackage{lipsum}
usepackage{array}
usepackage{varwidth}
usepackage{changepage}
strictpagecheck
defmaxwidth{13cm}
newcolumntype{M}{>{begin{varwidth}{maxwidth}}l<{end{varwidth}}}
newenvironment{myenvi}
{%
checkoddpage
ifoddpage
hfillbegin{tabular}{@{}M@{}}
fi
}
{%
checkoddpage
ifoddpage
end{tabular}hspace{-3.5pt}
fi
}

setlength{parskip}{1ex}
begin{document}
lipsum[1]

begin{myenvi}
Oh, this is what I want!

I really want some lines like this

And this line is a bit too long, so it will be broken to some lines blah blah. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines.
end{myenvi}

And some more normal lines

begin{myenvi}
This is a short text for testing whose total width is clearly less than 10cm.

And this is an even shorter text.
end{myenvi}

lipsum[2-6]

begin{myenvi}
This is the environment for check in an even page. It should be like normal text.

Yes, this is normal text!
end{myenvi}

lipsum[7]
end{document}


Page 1 (odd):



enter image description here



Page 2 (even):



enter image description here



Original answer



Define a new tabular column type and use hfill



documentclass{article}
usepackage{lipsum}
usepackage{array}
usepackage{varwidth}
newcolumntype{M}{>{begin{varwidth}{10cm}}l<{end{varwidth}}}

setlength{parskip}{1ex}
begin{document}
lipsum[1]

hfillbegin{tabular}{@{}M@{}}
Oh, this is what I want!

I really want some lines like this

And this line is a bit too long, so it will be broken to some lines blah blah. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines.
end{tabular}

lipsum[2]
end{document}


enter image description here






share|improve this answer















Click on the images to see it in a better resolution



Edit 1: Odd/even page check added



documentclass{article}
usepackage[showframe]{geometry}
usepackage{lipsum}
usepackage{array}
usepackage{varwidth}
usepackage{changepage}
strictpagecheck
defmaxwidth{13cm}
newcolumntype{M}{>{begin{varwidth}{maxwidth}}l<{end{varwidth}}}
newenvironment{myenvi}
{%
checkoddpage
ifoddpage
hfillbegin{tabular}{@{}M@{}}
fi
}
{%
checkoddpage
ifoddpage
end{tabular}hspace{-3.5pt}
fi
}

setlength{parskip}{1ex}
begin{document}
lipsum[1]

begin{myenvi}
Oh, this is what I want!

I really want some lines like this

And this line is a bit too long, so it will be broken to some lines blah blah. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines.
end{myenvi}

And some more normal lines

begin{myenvi}
This is a short text for testing whose total width is clearly less than 10cm.

And this is an even shorter text.
end{myenvi}

lipsum[2-6]

begin{myenvi}
This is the environment for check in an even page. It should be like normal text.

Yes, this is normal text!
end{myenvi}

lipsum[7]
end{document}


Page 1 (odd):



enter image description here



Page 2 (even):



enter image description here



Original answer



Define a new tabular column type and use hfill



documentclass{article}
usepackage{lipsum}
usepackage{array}
usepackage{varwidth}
newcolumntype{M}{>{begin{varwidth}{10cm}}l<{end{varwidth}}}

setlength{parskip}{1ex}
begin{document}
lipsum[1]

hfillbegin{tabular}{@{}M@{}}
Oh, this is what I want!

I really want some lines like this

And this line is a bit too long, so it will be broken to some lines blah blah. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines.
end{tabular}

lipsum[2]
end{document}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 8 at 12:00

























answered Mar 8 at 10:49









JouleVJouleV

5,97821549




5,97821549













  • Thanks, that's pretty cool, but to make the solution practical for my case, do you think there would there be a way to define this automatically for columns in odd pages only? Also, how can I affect the length of the space at which the long line will be broken?

    – ranavir
    Mar 8 at 11:33













  • @ranavir For the first question: This is only a hfill and an environment combined, so you can add this anywhere. If you want this on an odd page, add this on that page!

    – JouleV
    Mar 8 at 11:36











  • @ranavir For the second question: Look at the newcolumntype. You see a number 10cm. That is the width of the text. You can always change it, of course.

    – JouleV
    Mar 8 at 11:37











  • Ok, I get it. There are unfortunately two reasons why this is not practical. 1) I don't know the width number beforehand, I want it to be set to the longest line in the box. (Imagine this is e.g. a book of songs or poems with short lines.) 2) I don't know in advance which page is odd and which is even. The publication is sorted and rolling, so inserting a new page would mean I have to go and change all the subsequent pages manually.

    – ranavir
    Mar 8 at 11:40











  • @ranavir (1) Have you checked my code? 10cm is only the maximum width, not the width. Delete the And this line is a bit too long, so it ... and see what happens.

    – JouleV
    Mar 8 at 11:46



















  • Thanks, that's pretty cool, but to make the solution practical for my case, do you think there would there be a way to define this automatically for columns in odd pages only? Also, how can I affect the length of the space at which the long line will be broken?

    – ranavir
    Mar 8 at 11:33













  • @ranavir For the first question: This is only a hfill and an environment combined, so you can add this anywhere. If you want this on an odd page, add this on that page!

    – JouleV
    Mar 8 at 11:36











  • @ranavir For the second question: Look at the newcolumntype. You see a number 10cm. That is the width of the text. You can always change it, of course.

    – JouleV
    Mar 8 at 11:37











  • Ok, I get it. There are unfortunately two reasons why this is not practical. 1) I don't know the width number beforehand, I want it to be set to the longest line in the box. (Imagine this is e.g. a book of songs or poems with short lines.) 2) I don't know in advance which page is odd and which is even. The publication is sorted and rolling, so inserting a new page would mean I have to go and change all the subsequent pages manually.

    – ranavir
    Mar 8 at 11:40











  • @ranavir (1) Have you checked my code? 10cm is only the maximum width, not the width. Delete the And this line is a bit too long, so it ... and see what happens.

    – JouleV
    Mar 8 at 11:46

















Thanks, that's pretty cool, but to make the solution practical for my case, do you think there would there be a way to define this automatically for columns in odd pages only? Also, how can I affect the length of the space at which the long line will be broken?

– ranavir
Mar 8 at 11:33







Thanks, that's pretty cool, but to make the solution practical for my case, do you think there would there be a way to define this automatically for columns in odd pages only? Also, how can I affect the length of the space at which the long line will be broken?

– ranavir
Mar 8 at 11:33















@ranavir For the first question: This is only a hfill and an environment combined, so you can add this anywhere. If you want this on an odd page, add this on that page!

– JouleV
Mar 8 at 11:36





@ranavir For the first question: This is only a hfill and an environment combined, so you can add this anywhere. If you want this on an odd page, add this on that page!

– JouleV
Mar 8 at 11:36













@ranavir For the second question: Look at the newcolumntype. You see a number 10cm. That is the width of the text. You can always change it, of course.

– JouleV
Mar 8 at 11:37





@ranavir For the second question: Look at the newcolumntype. You see a number 10cm. That is the width of the text. You can always change it, of course.

– JouleV
Mar 8 at 11:37













Ok, I get it. There are unfortunately two reasons why this is not practical. 1) I don't know the width number beforehand, I want it to be set to the longest line in the box. (Imagine this is e.g. a book of songs or poems with short lines.) 2) I don't know in advance which page is odd and which is even. The publication is sorted and rolling, so inserting a new page would mean I have to go and change all the subsequent pages manually.

– ranavir
Mar 8 at 11:40





Ok, I get it. There are unfortunately two reasons why this is not practical. 1) I don't know the width number beforehand, I want it to be set to the longest line in the box. (Imagine this is e.g. a book of songs or poems with short lines.) 2) I don't know in advance which page is odd and which is even. The publication is sorted and rolling, so inserting a new page would mean I have to go and change all the subsequent pages manually.

– ranavir
Mar 8 at 11:40













@ranavir (1) Have you checked my code? 10cm is only the maximum width, not the width. Delete the And this line is a bit too long, so it ... and see what happens.

– JouleV
Mar 8 at 11:46





@ranavir (1) Have you checked my code? 10cm is only the maximum width, not the width. Delete the And this line is a bit too long, so it ... and see what happens.

– JouleV
Mar 8 at 11:46


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478389%2fmulticolumn-justify-left-and-fill-unused-space-from-the-left-odd-pages%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to send String Array data to Server using php in android

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Is anime1.com a legal site for watching anime?