How to make a 0pt height box?












4















We can use makebox[0pt]{text} to make a box that is logically 0pt width to external (as if nothing existed to the surroundings, while actually we can put whatever in it).
My questions is---what is the counterpart command to make the height of a box appear to be 0pt, logically, to its adjacent boxes.
With such a box, after a newline, next line will appear at the vertical position of the previous line on the same page.










share|improve this question























  • raisebox{0pt}[0pt][0pt]{text}.

    – egreg
    Jan 11 at 8:55











  • @egreg Thanks. But I tried raisebox{0pt}[0pt][0pt]{Some text}par{More text} but didn't get what's expected.

    – Max
    Jan 11 at 9:16






  • 2





    Max you got what @egreg expected, but we don't know what you expected unless you say what you want or expect.

    – David Carlisle
    Jan 11 at 9:19













  • Haha, what I expected was the 'next' new line appearing at the vertical position of previous line (with 0pt height), i.e. overlapping.

    – Max
    Jan 11 at 9:21











  • @Max: You still two lines. The raisebox makes the content zero height but a text line is still generated with baselineskip between it and the next line. If you want to overprint this way you need to add negative vertical space instead: like parvspace{-baselineskip}. It is about if you are in horizontal mode (e.g. inside a text line) or vertical mode (e.g. between paragraphs). TeX does react differently in these modes.

    – Martin Scharrer
    Jan 11 at 10:11


















4















We can use makebox[0pt]{text} to make a box that is logically 0pt width to external (as if nothing existed to the surroundings, while actually we can put whatever in it).
My questions is---what is the counterpart command to make the height of a box appear to be 0pt, logically, to its adjacent boxes.
With such a box, after a newline, next line will appear at the vertical position of the previous line on the same page.










share|improve this question























  • raisebox{0pt}[0pt][0pt]{text}.

    – egreg
    Jan 11 at 8:55











  • @egreg Thanks. But I tried raisebox{0pt}[0pt][0pt]{Some text}par{More text} but didn't get what's expected.

    – Max
    Jan 11 at 9:16






  • 2





    Max you got what @egreg expected, but we don't know what you expected unless you say what you want or expect.

    – David Carlisle
    Jan 11 at 9:19













  • Haha, what I expected was the 'next' new line appearing at the vertical position of previous line (with 0pt height), i.e. overlapping.

    – Max
    Jan 11 at 9:21











  • @Max: You still two lines. The raisebox makes the content zero height but a text line is still generated with baselineskip between it and the next line. If you want to overprint this way you need to add negative vertical space instead: like parvspace{-baselineskip}. It is about if you are in horizontal mode (e.g. inside a text line) or vertical mode (e.g. between paragraphs). TeX does react differently in these modes.

    – Martin Scharrer
    Jan 11 at 10:11
















4












4








4


1






We can use makebox[0pt]{text} to make a box that is logically 0pt width to external (as if nothing existed to the surroundings, while actually we can put whatever in it).
My questions is---what is the counterpart command to make the height of a box appear to be 0pt, logically, to its adjacent boxes.
With such a box, after a newline, next line will appear at the vertical position of the previous line on the same page.










share|improve this question














We can use makebox[0pt]{text} to make a box that is logically 0pt width to external (as if nothing existed to the surroundings, while actually we can put whatever in it).
My questions is---what is the counterpart command to make the height of a box appear to be 0pt, logically, to its adjacent boxes.
With such a box, after a newline, next line will appear at the vertical position of the previous line on the same page.







height box






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 11 at 8:49









MaxMax

305




305













  • raisebox{0pt}[0pt][0pt]{text}.

    – egreg
    Jan 11 at 8:55











  • @egreg Thanks. But I tried raisebox{0pt}[0pt][0pt]{Some text}par{More text} but didn't get what's expected.

    – Max
    Jan 11 at 9:16






  • 2





    Max you got what @egreg expected, but we don't know what you expected unless you say what you want or expect.

    – David Carlisle
    Jan 11 at 9:19













  • Haha, what I expected was the 'next' new line appearing at the vertical position of previous line (with 0pt height), i.e. overlapping.

    – Max
    Jan 11 at 9:21











  • @Max: You still two lines. The raisebox makes the content zero height but a text line is still generated with baselineskip between it and the next line. If you want to overprint this way you need to add negative vertical space instead: like parvspace{-baselineskip}. It is about if you are in horizontal mode (e.g. inside a text line) or vertical mode (e.g. between paragraphs). TeX does react differently in these modes.

    – Martin Scharrer
    Jan 11 at 10:11





















  • raisebox{0pt}[0pt][0pt]{text}.

    – egreg
    Jan 11 at 8:55











  • @egreg Thanks. But I tried raisebox{0pt}[0pt][0pt]{Some text}par{More text} but didn't get what's expected.

    – Max
    Jan 11 at 9:16






  • 2





    Max you got what @egreg expected, but we don't know what you expected unless you say what you want or expect.

    – David Carlisle
    Jan 11 at 9:19













  • Haha, what I expected was the 'next' new line appearing at the vertical position of previous line (with 0pt height), i.e. overlapping.

    – Max
    Jan 11 at 9:21











  • @Max: You still two lines. The raisebox makes the content zero height but a text line is still generated with baselineskip between it and the next line. If you want to overprint this way you need to add negative vertical space instead: like parvspace{-baselineskip}. It is about if you are in horizontal mode (e.g. inside a text line) or vertical mode (e.g. between paragraphs). TeX does react differently in these modes.

    – Martin Scharrer
    Jan 11 at 10:11



















raisebox{0pt}[0pt][0pt]{text}.

– egreg
Jan 11 at 8:55





raisebox{0pt}[0pt][0pt]{text}.

– egreg
Jan 11 at 8:55













@egreg Thanks. But I tried raisebox{0pt}[0pt][0pt]{Some text}par{More text} but didn't get what's expected.

– Max
Jan 11 at 9:16





@egreg Thanks. But I tried raisebox{0pt}[0pt][0pt]{Some text}par{More text} but didn't get what's expected.

– Max
Jan 11 at 9:16




2




2





Max you got what @egreg expected, but we don't know what you expected unless you say what you want or expect.

– David Carlisle
Jan 11 at 9:19







Max you got what @egreg expected, but we don't know what you expected unless you say what you want or expect.

– David Carlisle
Jan 11 at 9:19















Haha, what I expected was the 'next' new line appearing at the vertical position of previous line (with 0pt height), i.e. overlapping.

– Max
Jan 11 at 9:21





Haha, what I expected was the 'next' new line appearing at the vertical position of previous line (with 0pt height), i.e. overlapping.

– Max
Jan 11 at 9:21













@Max: You still two lines. The raisebox makes the content zero height but a text line is still generated with baselineskip between it and the next line. If you want to overprint this way you need to add negative vertical space instead: like parvspace{-baselineskip}. It is about if you are in horizontal mode (e.g. inside a text line) or vertical mode (e.g. between paragraphs). TeX does react differently in these modes.

– Martin Scharrer
Jan 11 at 10:11







@Max: You still two lines. The raisebox makes the content zero height but a text line is still generated with baselineskip between it and the next line. If you want to overprint this way you need to add negative vertical space instead: like parvspace{-baselineskip}. It is about if you are in horizontal mode (e.g. inside a text line) or vertical mode (e.g. between paragraphs). TeX does react differently in these modes.

– Martin Scharrer
Jan 11 at 10:11












3 Answers
3






active

oldest

votes


















7














To answer your written question: you can remove the height of a box by storing into a box register and set the height to 0pt and then use that box. You might also want to set the depth to 0pt. Ways of easily do this is the adjustbox package: adjustbox{set height=0pt, set depth=0pt}{Some Text} or, without a package, raisebox{0pt}[0pt][0pt]{Some Text}.



Note that this just makes the box have no official vertical size, but it is still placed in a horizontal list which makes up the line. Inside a paragraph all characters and other material like images are modeled by TeX as boxes with a height, depth and width and placed on a list which makes up a line, until enough is there to build a full line. All of these boxes sit on a line, the baseline, everything above that line makes up the height, everything below the depth. TeX usually places the amount baselineskip between the baselines of two sequential lines.



Therefore if you want to overprint the following line over the last line, deleting the official height and depth of the content of the first line has no effect, because the baselineskip is still added. In order to achieve this you need to undo the baselineskip again so that the second line starts at the same vertical position as the first. This can be done using vspace{-baselineskip} between the two lines, in most cases. Note that if the first line contains material with a very large depth, then the two lines will be more than baselineskip apart! Also if you have a paragraph break there then LaTeX might add more space between the last line of the last paragraph and the first line of the following paragraph depending on global settings (e.g. using the parskip package; used to get German paragraph style). Also LaTeX tries to spread the paragraphs across the page if flushbottom is active by increasing inter-paragraph spacing. In such cases, you might want to use \ instead of par.






share|improve this answer
























  • Wouldn't vspace{glueexpr-baselineskip-parskip} (or two negative vspaces) still do the trick with par and flushbottom because the stretch/shrink components also cancel out?

    – Circumscribe
    Jan 12 at 18:45











  • @Circumscribe: Well, adding parskip is a good idea, but might not enough, because AFAIK TeX might add more space in some cases. I would need to check The TeXBook again.

    – Martin Scharrer
    Jan 12 at 19:52











  • It is my understanding that in case of an underfull vbox the space that is added is still divided over the already present vertical skips in proportion to their stretch values and that this is no different for negative values. So whenever a parskip is stretched, a manually inserted vspace{-parskip} on the same page would be anti-stretched (I'm deliberately not saying "shrunk") by the same amount. There could well be exceptions though.

    – Circumscribe
    Jan 12 at 20:39



















5














documentclass{article}
usepackage{color}
newboxmybox
begin{document}
Some text pppp

Some text pppp

setboxmyboxvbox{% some arbitrary contents
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace*{1cm}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
% insert it in a way keeping prevdepth
setboxmyboxvbox{boxmybox}
unvboxmybox

Some text pppp

Some text pppp
end{document}


enter image description here



Circumscribe suggestion: (if inserted contents are also paragraph like, hence one may want some alignment)



documentclass{article}
usepackage{color}
newboxmybox
newdimenmyprevdepth
begin{document}
Some text pppp

Some text pppp

myprevdepthprevdepth
setboxmyboxvbox{% some arbitrary contents
prevdepthmyprevdepth
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace{2baselineskip}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzdotfillpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
% insert it in a way keeping prevdepth
setboxmyboxvbox{boxmybox}
unvboxmybox

Some text ppppdotfill

Some text ppppdotfill

And more paragraphs...

mbox{}cleaders hbox to .44em{hss .hss }hskip5cm This is regular
textdotfillnewline which continues heredotfill

end{document}


enter image description here



I am adding a variant which avoids the unvbox trick and needs no handling of prevdepth.



documentclass{article}
usepackage{color}
newboxmybox
begin{document}parskip2pt
Some text pppp (parskip is 2pt in this example)

Some textrule{1cm}{1pt} pppp

setboxmyboxvtop{% some arbitrary contents
hrule height 0pt
vbox{}vskip-baselineskip
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace{dimexpr2baselineskip+parskiprelax}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzdotfillpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
boxmybox % this will get the correct baseline
vskip-baselineskip

Some text ppppsmash{rule{1pt}{dimexprbaselineskip+parskip}}dotfill

Some text ppppdotfill

And more paragraphs...

mbox{}cleaders hbox to .44em{hss .hss }hskip5cm This is regular
textdotfillnewline which continues heredotfill

end{document}


enter image description here






share|improve this answer


























  • @Circumsrcibe, Yes, good idea, see edit. Initially I remained agnostic about what was the goal of the inserted box.

    – jfbu
    Jan 12 at 21:26













  • Makes sense, but I expect this'll probably match OP's expectations better. I'd +1 again if I could.

    – Circumscribe
    Jan 12 at 21:38













  • @Circumscribe I could circumscribe usage of prevdepth.

    – jfbu
    Jan 12 at 22:08











  • Heh, having to know the value of prevdepth when creating the box does seem undesirable. This last version no longer works if the line preceding the box is very deep or the one following it is very tall though.

    – Circumscribe
    Jan 12 at 22:25













  • @jfbu: Thanks. That's looks interesting. Can you please add some comments in the code?

    – Max
    Jan 13 at 9:09



















3














This is essentially just a comment, but it doesn’t fit in 600 characters: is it this what you are trying to achieve?



% My standard header for TeX.SX answers:
documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.

newenvironment*{overlap}{%
par
null
setlengthbaselineskip{0pt}%
setlengthlineskip{0pt}%
setlengthlineskiplimit{-maxdimen}%
setlengthparskip{0pt}%
}{par}



begin{document}

This is too long for a comment: is it this what you expected?

begin{overlap}
noindent A few\
makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

..................................And another paragraph.
end{overlap}
More text.

end{document}


I forgot: this is the output.



Output of the code





The OP asked for a version of the above that doesn’t break down when the font size is changed; here it is:



% My standard header for TeX.SX answers:
documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.

usepackage{color}

newenvironment*{overlap}{%
par
null
linespread{0}selectfont
setlengthlineskip{0pt}%
setlengthlineskiplimit{-maxdimen}%
setlengthparskip{0pt}%
}{par}



begin{document}

This is too long for a comment: is it this what you expected?
begin{overlap}
noindent A few\
makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

..................................And another paragraph.
end{overlap}
More text.

Now it works also if you change the font size:
begin{overlap}
noindent A few\
Large makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

color{cyan}Huge ..................................And another paragraph.
end{overlap}
Still more text.

end{document}


The corrseponding output:



Output of the second code sample



I’m not (yet) going to provide explanations, because it is still unclear whether or not this is what the OP is trying to achieve.






share|improve this answer


























  • That's exactly the effect I meant and is interesting. But when I changed a bit `makebox[1cm]{}Huge{overlapping}` it didn't work any more.

    – Max
    Jan 13 at 9:00











  • @Max: This is because Huge also changes baselineskip, lineskip lineskiplimit; it works if you use {Huge overlapping} because these changes are then undone before the paragraph ends. You may also want to have a look at this question about the usage of Huge and its ilk.

    – Circumscribe
    Jan 13 at 15:05











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%2f469659%2fhow-to-make-a-0pt-height-box%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









7














To answer your written question: you can remove the height of a box by storing into a box register and set the height to 0pt and then use that box. You might also want to set the depth to 0pt. Ways of easily do this is the adjustbox package: adjustbox{set height=0pt, set depth=0pt}{Some Text} or, without a package, raisebox{0pt}[0pt][0pt]{Some Text}.



Note that this just makes the box have no official vertical size, but it is still placed in a horizontal list which makes up the line. Inside a paragraph all characters and other material like images are modeled by TeX as boxes with a height, depth and width and placed on a list which makes up a line, until enough is there to build a full line. All of these boxes sit on a line, the baseline, everything above that line makes up the height, everything below the depth. TeX usually places the amount baselineskip between the baselines of two sequential lines.



Therefore if you want to overprint the following line over the last line, deleting the official height and depth of the content of the first line has no effect, because the baselineskip is still added. In order to achieve this you need to undo the baselineskip again so that the second line starts at the same vertical position as the first. This can be done using vspace{-baselineskip} between the two lines, in most cases. Note that if the first line contains material with a very large depth, then the two lines will be more than baselineskip apart! Also if you have a paragraph break there then LaTeX might add more space between the last line of the last paragraph and the first line of the following paragraph depending on global settings (e.g. using the parskip package; used to get German paragraph style). Also LaTeX tries to spread the paragraphs across the page if flushbottom is active by increasing inter-paragraph spacing. In such cases, you might want to use \ instead of par.






share|improve this answer
























  • Wouldn't vspace{glueexpr-baselineskip-parskip} (or two negative vspaces) still do the trick with par and flushbottom because the stretch/shrink components also cancel out?

    – Circumscribe
    Jan 12 at 18:45











  • @Circumscribe: Well, adding parskip is a good idea, but might not enough, because AFAIK TeX might add more space in some cases. I would need to check The TeXBook again.

    – Martin Scharrer
    Jan 12 at 19:52











  • It is my understanding that in case of an underfull vbox the space that is added is still divided over the already present vertical skips in proportion to their stretch values and that this is no different for negative values. So whenever a parskip is stretched, a manually inserted vspace{-parskip} on the same page would be anti-stretched (I'm deliberately not saying "shrunk") by the same amount. There could well be exceptions though.

    – Circumscribe
    Jan 12 at 20:39
















7














To answer your written question: you can remove the height of a box by storing into a box register and set the height to 0pt and then use that box. You might also want to set the depth to 0pt. Ways of easily do this is the adjustbox package: adjustbox{set height=0pt, set depth=0pt}{Some Text} or, without a package, raisebox{0pt}[0pt][0pt]{Some Text}.



Note that this just makes the box have no official vertical size, but it is still placed in a horizontal list which makes up the line. Inside a paragraph all characters and other material like images are modeled by TeX as boxes with a height, depth and width and placed on a list which makes up a line, until enough is there to build a full line. All of these boxes sit on a line, the baseline, everything above that line makes up the height, everything below the depth. TeX usually places the amount baselineskip between the baselines of two sequential lines.



Therefore if you want to overprint the following line over the last line, deleting the official height and depth of the content of the first line has no effect, because the baselineskip is still added. In order to achieve this you need to undo the baselineskip again so that the second line starts at the same vertical position as the first. This can be done using vspace{-baselineskip} between the two lines, in most cases. Note that if the first line contains material with a very large depth, then the two lines will be more than baselineskip apart! Also if you have a paragraph break there then LaTeX might add more space between the last line of the last paragraph and the first line of the following paragraph depending on global settings (e.g. using the parskip package; used to get German paragraph style). Also LaTeX tries to spread the paragraphs across the page if flushbottom is active by increasing inter-paragraph spacing. In such cases, you might want to use \ instead of par.






share|improve this answer
























  • Wouldn't vspace{glueexpr-baselineskip-parskip} (or two negative vspaces) still do the trick with par and flushbottom because the stretch/shrink components also cancel out?

    – Circumscribe
    Jan 12 at 18:45











  • @Circumscribe: Well, adding parskip is a good idea, but might not enough, because AFAIK TeX might add more space in some cases. I would need to check The TeXBook again.

    – Martin Scharrer
    Jan 12 at 19:52











  • It is my understanding that in case of an underfull vbox the space that is added is still divided over the already present vertical skips in proportion to their stretch values and that this is no different for negative values. So whenever a parskip is stretched, a manually inserted vspace{-parskip} on the same page would be anti-stretched (I'm deliberately not saying "shrunk") by the same amount. There could well be exceptions though.

    – Circumscribe
    Jan 12 at 20:39














7












7








7







To answer your written question: you can remove the height of a box by storing into a box register and set the height to 0pt and then use that box. You might also want to set the depth to 0pt. Ways of easily do this is the adjustbox package: adjustbox{set height=0pt, set depth=0pt}{Some Text} or, without a package, raisebox{0pt}[0pt][0pt]{Some Text}.



Note that this just makes the box have no official vertical size, but it is still placed in a horizontal list which makes up the line. Inside a paragraph all characters and other material like images are modeled by TeX as boxes with a height, depth and width and placed on a list which makes up a line, until enough is there to build a full line. All of these boxes sit on a line, the baseline, everything above that line makes up the height, everything below the depth. TeX usually places the amount baselineskip between the baselines of two sequential lines.



Therefore if you want to overprint the following line over the last line, deleting the official height and depth of the content of the first line has no effect, because the baselineskip is still added. In order to achieve this you need to undo the baselineskip again so that the second line starts at the same vertical position as the first. This can be done using vspace{-baselineskip} between the two lines, in most cases. Note that if the first line contains material with a very large depth, then the two lines will be more than baselineskip apart! Also if you have a paragraph break there then LaTeX might add more space between the last line of the last paragraph and the first line of the following paragraph depending on global settings (e.g. using the parskip package; used to get German paragraph style). Also LaTeX tries to spread the paragraphs across the page if flushbottom is active by increasing inter-paragraph spacing. In such cases, you might want to use \ instead of par.






share|improve this answer













To answer your written question: you can remove the height of a box by storing into a box register and set the height to 0pt and then use that box. You might also want to set the depth to 0pt. Ways of easily do this is the adjustbox package: adjustbox{set height=0pt, set depth=0pt}{Some Text} or, without a package, raisebox{0pt}[0pt][0pt]{Some Text}.



Note that this just makes the box have no official vertical size, but it is still placed in a horizontal list which makes up the line. Inside a paragraph all characters and other material like images are modeled by TeX as boxes with a height, depth and width and placed on a list which makes up a line, until enough is there to build a full line. All of these boxes sit on a line, the baseline, everything above that line makes up the height, everything below the depth. TeX usually places the amount baselineskip between the baselines of two sequential lines.



Therefore if you want to overprint the following line over the last line, deleting the official height and depth of the content of the first line has no effect, because the baselineskip is still added. In order to achieve this you need to undo the baselineskip again so that the second line starts at the same vertical position as the first. This can be done using vspace{-baselineskip} between the two lines, in most cases. Note that if the first line contains material with a very large depth, then the two lines will be more than baselineskip apart! Also if you have a paragraph break there then LaTeX might add more space between the last line of the last paragraph and the first line of the following paragraph depending on global settings (e.g. using the parskip package; used to get German paragraph style). Also LaTeX tries to spread the paragraphs across the page if flushbottom is active by increasing inter-paragraph spacing. In such cases, you might want to use \ instead of par.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 12 at 18:18









Martin ScharrerMartin Scharrer

200k45636818




200k45636818













  • Wouldn't vspace{glueexpr-baselineskip-parskip} (or two negative vspaces) still do the trick with par and flushbottom because the stretch/shrink components also cancel out?

    – Circumscribe
    Jan 12 at 18:45











  • @Circumscribe: Well, adding parskip is a good idea, but might not enough, because AFAIK TeX might add more space in some cases. I would need to check The TeXBook again.

    – Martin Scharrer
    Jan 12 at 19:52











  • It is my understanding that in case of an underfull vbox the space that is added is still divided over the already present vertical skips in proportion to their stretch values and that this is no different for negative values. So whenever a parskip is stretched, a manually inserted vspace{-parskip} on the same page would be anti-stretched (I'm deliberately not saying "shrunk") by the same amount. There could well be exceptions though.

    – Circumscribe
    Jan 12 at 20:39



















  • Wouldn't vspace{glueexpr-baselineskip-parskip} (or two negative vspaces) still do the trick with par and flushbottom because the stretch/shrink components also cancel out?

    – Circumscribe
    Jan 12 at 18:45











  • @Circumscribe: Well, adding parskip is a good idea, but might not enough, because AFAIK TeX might add more space in some cases. I would need to check The TeXBook again.

    – Martin Scharrer
    Jan 12 at 19:52











  • It is my understanding that in case of an underfull vbox the space that is added is still divided over the already present vertical skips in proportion to their stretch values and that this is no different for negative values. So whenever a parskip is stretched, a manually inserted vspace{-parskip} on the same page would be anti-stretched (I'm deliberately not saying "shrunk") by the same amount. There could well be exceptions though.

    – Circumscribe
    Jan 12 at 20:39

















Wouldn't vspace{glueexpr-baselineskip-parskip} (or two negative vspaces) still do the trick with par and flushbottom because the stretch/shrink components also cancel out?

– Circumscribe
Jan 12 at 18:45





Wouldn't vspace{glueexpr-baselineskip-parskip} (or two negative vspaces) still do the trick with par and flushbottom because the stretch/shrink components also cancel out?

– Circumscribe
Jan 12 at 18:45













@Circumscribe: Well, adding parskip is a good idea, but might not enough, because AFAIK TeX might add more space in some cases. I would need to check The TeXBook again.

– Martin Scharrer
Jan 12 at 19:52





@Circumscribe: Well, adding parskip is a good idea, but might not enough, because AFAIK TeX might add more space in some cases. I would need to check The TeXBook again.

– Martin Scharrer
Jan 12 at 19:52













It is my understanding that in case of an underfull vbox the space that is added is still divided over the already present vertical skips in proportion to their stretch values and that this is no different for negative values. So whenever a parskip is stretched, a manually inserted vspace{-parskip} on the same page would be anti-stretched (I'm deliberately not saying "shrunk") by the same amount. There could well be exceptions though.

– Circumscribe
Jan 12 at 20:39





It is my understanding that in case of an underfull vbox the space that is added is still divided over the already present vertical skips in proportion to their stretch values and that this is no different for negative values. So whenever a parskip is stretched, a manually inserted vspace{-parskip} on the same page would be anti-stretched (I'm deliberately not saying "shrunk") by the same amount. There could well be exceptions though.

– Circumscribe
Jan 12 at 20:39











5














documentclass{article}
usepackage{color}
newboxmybox
begin{document}
Some text pppp

Some text pppp

setboxmyboxvbox{% some arbitrary contents
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace*{1cm}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
% insert it in a way keeping prevdepth
setboxmyboxvbox{boxmybox}
unvboxmybox

Some text pppp

Some text pppp
end{document}


enter image description here



Circumscribe suggestion: (if inserted contents are also paragraph like, hence one may want some alignment)



documentclass{article}
usepackage{color}
newboxmybox
newdimenmyprevdepth
begin{document}
Some text pppp

Some text pppp

myprevdepthprevdepth
setboxmyboxvbox{% some arbitrary contents
prevdepthmyprevdepth
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace{2baselineskip}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzdotfillpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
% insert it in a way keeping prevdepth
setboxmyboxvbox{boxmybox}
unvboxmybox

Some text ppppdotfill

Some text ppppdotfill

And more paragraphs...

mbox{}cleaders hbox to .44em{hss .hss }hskip5cm This is regular
textdotfillnewline which continues heredotfill

end{document}


enter image description here



I am adding a variant which avoids the unvbox trick and needs no handling of prevdepth.



documentclass{article}
usepackage{color}
newboxmybox
begin{document}parskip2pt
Some text pppp (parskip is 2pt in this example)

Some textrule{1cm}{1pt} pppp

setboxmyboxvtop{% some arbitrary contents
hrule height 0pt
vbox{}vskip-baselineskip
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace{dimexpr2baselineskip+parskiprelax}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzdotfillpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
boxmybox % this will get the correct baseline
vskip-baselineskip

Some text ppppsmash{rule{1pt}{dimexprbaselineskip+parskip}}dotfill

Some text ppppdotfill

And more paragraphs...

mbox{}cleaders hbox to .44em{hss .hss }hskip5cm This is regular
textdotfillnewline which continues heredotfill

end{document}


enter image description here






share|improve this answer


























  • @Circumsrcibe, Yes, good idea, see edit. Initially I remained agnostic about what was the goal of the inserted box.

    – jfbu
    Jan 12 at 21:26













  • Makes sense, but I expect this'll probably match OP's expectations better. I'd +1 again if I could.

    – Circumscribe
    Jan 12 at 21:38













  • @Circumscribe I could circumscribe usage of prevdepth.

    – jfbu
    Jan 12 at 22:08











  • Heh, having to know the value of prevdepth when creating the box does seem undesirable. This last version no longer works if the line preceding the box is very deep or the one following it is very tall though.

    – Circumscribe
    Jan 12 at 22:25













  • @jfbu: Thanks. That's looks interesting. Can you please add some comments in the code?

    – Max
    Jan 13 at 9:09
















5














documentclass{article}
usepackage{color}
newboxmybox
begin{document}
Some text pppp

Some text pppp

setboxmyboxvbox{% some arbitrary contents
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace*{1cm}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
% insert it in a way keeping prevdepth
setboxmyboxvbox{boxmybox}
unvboxmybox

Some text pppp

Some text pppp
end{document}


enter image description here



Circumscribe suggestion: (if inserted contents are also paragraph like, hence one may want some alignment)



documentclass{article}
usepackage{color}
newboxmybox
newdimenmyprevdepth
begin{document}
Some text pppp

Some text pppp

myprevdepthprevdepth
setboxmyboxvbox{% some arbitrary contents
prevdepthmyprevdepth
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace{2baselineskip}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzdotfillpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
% insert it in a way keeping prevdepth
setboxmyboxvbox{boxmybox}
unvboxmybox

Some text ppppdotfill

Some text ppppdotfill

And more paragraphs...

mbox{}cleaders hbox to .44em{hss .hss }hskip5cm This is regular
textdotfillnewline which continues heredotfill

end{document}


enter image description here



I am adding a variant which avoids the unvbox trick and needs no handling of prevdepth.



documentclass{article}
usepackage{color}
newboxmybox
begin{document}parskip2pt
Some text pppp (parskip is 2pt in this example)

Some textrule{1cm}{1pt} pppp

setboxmyboxvtop{% some arbitrary contents
hrule height 0pt
vbox{}vskip-baselineskip
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace{dimexpr2baselineskip+parskiprelax}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzdotfillpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
boxmybox % this will get the correct baseline
vskip-baselineskip

Some text ppppsmash{rule{1pt}{dimexprbaselineskip+parskip}}dotfill

Some text ppppdotfill

And more paragraphs...

mbox{}cleaders hbox to .44em{hss .hss }hskip5cm This is regular
textdotfillnewline which continues heredotfill

end{document}


enter image description here






share|improve this answer


























  • @Circumsrcibe, Yes, good idea, see edit. Initially I remained agnostic about what was the goal of the inserted box.

    – jfbu
    Jan 12 at 21:26













  • Makes sense, but I expect this'll probably match OP's expectations better. I'd +1 again if I could.

    – Circumscribe
    Jan 12 at 21:38













  • @Circumscribe I could circumscribe usage of prevdepth.

    – jfbu
    Jan 12 at 22:08











  • Heh, having to know the value of prevdepth when creating the box does seem undesirable. This last version no longer works if the line preceding the box is very deep or the one following it is very tall though.

    – Circumscribe
    Jan 12 at 22:25













  • @jfbu: Thanks. That's looks interesting. Can you please add some comments in the code?

    – Max
    Jan 13 at 9:09














5












5








5







documentclass{article}
usepackage{color}
newboxmybox
begin{document}
Some text pppp

Some text pppp

setboxmyboxvbox{% some arbitrary contents
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace*{1cm}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
% insert it in a way keeping prevdepth
setboxmyboxvbox{boxmybox}
unvboxmybox

Some text pppp

Some text pppp
end{document}


enter image description here



Circumscribe suggestion: (if inserted contents are also paragraph like, hence one may want some alignment)



documentclass{article}
usepackage{color}
newboxmybox
newdimenmyprevdepth
begin{document}
Some text pppp

Some text pppp

myprevdepthprevdepth
setboxmyboxvbox{% some arbitrary contents
prevdepthmyprevdepth
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace{2baselineskip}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzdotfillpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
% insert it in a way keeping prevdepth
setboxmyboxvbox{boxmybox}
unvboxmybox

Some text ppppdotfill

Some text ppppdotfill

And more paragraphs...

mbox{}cleaders hbox to .44em{hss .hss }hskip5cm This is regular
textdotfillnewline which continues heredotfill

end{document}


enter image description here



I am adding a variant which avoids the unvbox trick and needs no handling of prevdepth.



documentclass{article}
usepackage{color}
newboxmybox
begin{document}parskip2pt
Some text pppp (parskip is 2pt in this example)

Some textrule{1cm}{1pt} pppp

setboxmyboxvtop{% some arbitrary contents
hrule height 0pt
vbox{}vskip-baselineskip
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace{dimexpr2baselineskip+parskiprelax}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzdotfillpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
boxmybox % this will get the correct baseline
vskip-baselineskip

Some text ppppsmash{rule{1pt}{dimexprbaselineskip+parskip}}dotfill

Some text ppppdotfill

And more paragraphs...

mbox{}cleaders hbox to .44em{hss .hss }hskip5cm This is regular
textdotfillnewline which continues heredotfill

end{document}


enter image description here






share|improve this answer















documentclass{article}
usepackage{color}
newboxmybox
begin{document}
Some text pppp

Some text pppp

setboxmyboxvbox{% some arbitrary contents
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace*{1cm}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
% insert it in a way keeping prevdepth
setboxmyboxvbox{boxmybox}
unvboxmybox

Some text pppp

Some text pppp
end{document}


enter image description here



Circumscribe suggestion: (if inserted contents are also paragraph like, hence one may want some alignment)



documentclass{article}
usepackage{color}
newboxmybox
newdimenmyprevdepth
begin{document}
Some text pppp

Some text pppp

myprevdepthprevdepth
setboxmyboxvbox{% some arbitrary contents
prevdepthmyprevdepth
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace{2baselineskip}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzdotfillpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
% insert it in a way keeping prevdepth
setboxmyboxvbox{boxmybox}
unvboxmybox

Some text ppppdotfill

Some text ppppdotfill

And more paragraphs...

mbox{}cleaders hbox to .44em{hss .hss }hskip5cm This is regular
textdotfillnewline which continues heredotfill

end{document}


enter image description here



I am adding a variant which avoids the unvbox trick and needs no handling of prevdepth.



documentclass{article}
usepackage{color}
newboxmybox
begin{document}parskip2pt
Some text pppp (parskip is 2pt in this example)

Some textrule{1cm}{1pt} pppp

setboxmyboxvtop{% some arbitrary contents
hrule height 0pt
vbox{}vskip-baselineskip
begingroupcolor{red}
% some paragraphs
hspace*{5cm}aaa, bbb, cccpar
hspace*{5cm}ppp, qqq, rrrpar
% some vertical space
vspace{dimexpr2baselineskip+parskiprelax}
% some more paragraphs
hspace*{5cm}uuu, vvv, wwwpar
hspace*{5cm}xxx, yyy, zzzdotfillpar
endgroup}
% set the box to occupy zero space
htmybox0pt
dpmybox0pt
boxmybox % this will get the correct baseline
vskip-baselineskip

Some text ppppsmash{rule{1pt}{dimexprbaselineskip+parskip}}dotfill

Some text ppppdotfill

And more paragraphs...

mbox{}cleaders hbox to .44em{hss .hss }hskip5cm This is regular
textdotfillnewline which continues heredotfill

end{document}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 12 at 22:08

























answered Jan 12 at 20:52









jfbujfbu

46.6k66148




46.6k66148













  • @Circumsrcibe, Yes, good idea, see edit. Initially I remained agnostic about what was the goal of the inserted box.

    – jfbu
    Jan 12 at 21:26













  • Makes sense, but I expect this'll probably match OP's expectations better. I'd +1 again if I could.

    – Circumscribe
    Jan 12 at 21:38













  • @Circumscribe I could circumscribe usage of prevdepth.

    – jfbu
    Jan 12 at 22:08











  • Heh, having to know the value of prevdepth when creating the box does seem undesirable. This last version no longer works if the line preceding the box is very deep or the one following it is very tall though.

    – Circumscribe
    Jan 12 at 22:25













  • @jfbu: Thanks. That's looks interesting. Can you please add some comments in the code?

    – Max
    Jan 13 at 9:09



















  • @Circumsrcibe, Yes, good idea, see edit. Initially I remained agnostic about what was the goal of the inserted box.

    – jfbu
    Jan 12 at 21:26













  • Makes sense, but I expect this'll probably match OP's expectations better. I'd +1 again if I could.

    – Circumscribe
    Jan 12 at 21:38













  • @Circumscribe I could circumscribe usage of prevdepth.

    – jfbu
    Jan 12 at 22:08











  • Heh, having to know the value of prevdepth when creating the box does seem undesirable. This last version no longer works if the line preceding the box is very deep or the one following it is very tall though.

    – Circumscribe
    Jan 12 at 22:25













  • @jfbu: Thanks. That's looks interesting. Can you please add some comments in the code?

    – Max
    Jan 13 at 9:09

















@Circumsrcibe, Yes, good idea, see edit. Initially I remained agnostic about what was the goal of the inserted box.

– jfbu
Jan 12 at 21:26







@Circumsrcibe, Yes, good idea, see edit. Initially I remained agnostic about what was the goal of the inserted box.

– jfbu
Jan 12 at 21:26















Makes sense, but I expect this'll probably match OP's expectations better. I'd +1 again if I could.

– Circumscribe
Jan 12 at 21:38







Makes sense, but I expect this'll probably match OP's expectations better. I'd +1 again if I could.

– Circumscribe
Jan 12 at 21:38















@Circumscribe I could circumscribe usage of prevdepth.

– jfbu
Jan 12 at 22:08





@Circumscribe I could circumscribe usage of prevdepth.

– jfbu
Jan 12 at 22:08













Heh, having to know the value of prevdepth when creating the box does seem undesirable. This last version no longer works if the line preceding the box is very deep or the one following it is very tall though.

– Circumscribe
Jan 12 at 22:25







Heh, having to know the value of prevdepth when creating the box does seem undesirable. This last version no longer works if the line preceding the box is very deep or the one following it is very tall though.

– Circumscribe
Jan 12 at 22:25















@jfbu: Thanks. That's looks interesting. Can you please add some comments in the code?

– Max
Jan 13 at 9:09





@jfbu: Thanks. That's looks interesting. Can you please add some comments in the code?

– Max
Jan 13 at 9:09











3














This is essentially just a comment, but it doesn’t fit in 600 characters: is it this what you are trying to achieve?



% My standard header for TeX.SX answers:
documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.

newenvironment*{overlap}{%
par
null
setlengthbaselineskip{0pt}%
setlengthlineskip{0pt}%
setlengthlineskiplimit{-maxdimen}%
setlengthparskip{0pt}%
}{par}



begin{document}

This is too long for a comment: is it this what you expected?

begin{overlap}
noindent A few\
makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

..................................And another paragraph.
end{overlap}
More text.

end{document}


I forgot: this is the output.



Output of the code





The OP asked for a version of the above that doesn’t break down when the font size is changed; here it is:



% My standard header for TeX.SX answers:
documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.

usepackage{color}

newenvironment*{overlap}{%
par
null
linespread{0}selectfont
setlengthlineskip{0pt}%
setlengthlineskiplimit{-maxdimen}%
setlengthparskip{0pt}%
}{par}



begin{document}

This is too long for a comment: is it this what you expected?
begin{overlap}
noindent A few\
makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

..................................And another paragraph.
end{overlap}
More text.

Now it works also if you change the font size:
begin{overlap}
noindent A few\
Large makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

color{cyan}Huge ..................................And another paragraph.
end{overlap}
Still more text.

end{document}


The corrseponding output:



Output of the second code sample



I’m not (yet) going to provide explanations, because it is still unclear whether or not this is what the OP is trying to achieve.






share|improve this answer


























  • That's exactly the effect I meant and is interesting. But when I changed a bit `makebox[1cm]{}Huge{overlapping}` it didn't work any more.

    – Max
    Jan 13 at 9:00











  • @Max: This is because Huge also changes baselineskip, lineskip lineskiplimit; it works if you use {Huge overlapping} because these changes are then undone before the paragraph ends. You may also want to have a look at this question about the usage of Huge and its ilk.

    – Circumscribe
    Jan 13 at 15:05
















3














This is essentially just a comment, but it doesn’t fit in 600 characters: is it this what you are trying to achieve?



% My standard header for TeX.SX answers:
documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.

newenvironment*{overlap}{%
par
null
setlengthbaselineskip{0pt}%
setlengthlineskip{0pt}%
setlengthlineskiplimit{-maxdimen}%
setlengthparskip{0pt}%
}{par}



begin{document}

This is too long for a comment: is it this what you expected?

begin{overlap}
noindent A few\
makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

..................................And another paragraph.
end{overlap}
More text.

end{document}


I forgot: this is the output.



Output of the code





The OP asked for a version of the above that doesn’t break down when the font size is changed; here it is:



% My standard header for TeX.SX answers:
documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.

usepackage{color}

newenvironment*{overlap}{%
par
null
linespread{0}selectfont
setlengthlineskip{0pt}%
setlengthlineskiplimit{-maxdimen}%
setlengthparskip{0pt}%
}{par}



begin{document}

This is too long for a comment: is it this what you expected?
begin{overlap}
noindent A few\
makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

..................................And another paragraph.
end{overlap}
More text.

Now it works also if you change the font size:
begin{overlap}
noindent A few\
Large makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

color{cyan}Huge ..................................And another paragraph.
end{overlap}
Still more text.

end{document}


The corrseponding output:



Output of the second code sample



I’m not (yet) going to provide explanations, because it is still unclear whether or not this is what the OP is trying to achieve.






share|improve this answer


























  • That's exactly the effect I meant and is interesting. But when I changed a bit `makebox[1cm]{}Huge{overlapping}` it didn't work any more.

    – Max
    Jan 13 at 9:00











  • @Max: This is because Huge also changes baselineskip, lineskip lineskiplimit; it works if you use {Huge overlapping} because these changes are then undone before the paragraph ends. You may also want to have a look at this question about the usage of Huge and its ilk.

    – Circumscribe
    Jan 13 at 15:05














3












3








3







This is essentially just a comment, but it doesn’t fit in 600 characters: is it this what you are trying to achieve?



% My standard header for TeX.SX answers:
documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.

newenvironment*{overlap}{%
par
null
setlengthbaselineskip{0pt}%
setlengthlineskip{0pt}%
setlengthlineskiplimit{-maxdimen}%
setlengthparskip{0pt}%
}{par}



begin{document}

This is too long for a comment: is it this what you expected?

begin{overlap}
noindent A few\
makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

..................................And another paragraph.
end{overlap}
More text.

end{document}


I forgot: this is the output.



Output of the code





The OP asked for a version of the above that doesn’t break down when the font size is changed; here it is:



% My standard header for TeX.SX answers:
documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.

usepackage{color}

newenvironment*{overlap}{%
par
null
linespread{0}selectfont
setlengthlineskip{0pt}%
setlengthlineskiplimit{-maxdimen}%
setlengthparskip{0pt}%
}{par}



begin{document}

This is too long for a comment: is it this what you expected?
begin{overlap}
noindent A few\
makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

..................................And another paragraph.
end{overlap}
More text.

Now it works also if you change the font size:
begin{overlap}
noindent A few\
Large makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

color{cyan}Huge ..................................And another paragraph.
end{overlap}
Still more text.

end{document}


The corrseponding output:



Output of the second code sample



I’m not (yet) going to provide explanations, because it is still unclear whether or not this is what the OP is trying to achieve.






share|improve this answer















This is essentially just a comment, but it doesn’t fit in 600 characters: is it this what you are trying to achieve?



% My standard header for TeX.SX answers:
documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.

newenvironment*{overlap}{%
par
null
setlengthbaselineskip{0pt}%
setlengthlineskip{0pt}%
setlengthlineskiplimit{-maxdimen}%
setlengthparskip{0pt}%
}{par}



begin{document}

This is too long for a comment: is it this what you expected?

begin{overlap}
noindent A few\
makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

..................................And another paragraph.
end{overlap}
More text.

end{document}


I forgot: this is the output.



Output of the code





The OP asked for a version of the above that doesn’t break down when the font size is changed; here it is:



% My standard header for TeX.SX answers:
documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.

usepackage{color}

newenvironment*{overlap}{%
par
null
linespread{0}selectfont
setlengthlineskip{0pt}%
setlengthlineskiplimit{-maxdimen}%
setlengthparskip{0pt}%
}{par}



begin{document}

This is too long for a comment: is it this what you expected?
begin{overlap}
noindent A few\
makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

..................................And another paragraph.
end{overlap}
More text.

Now it works also if you change the font size:
begin{overlap}
noindent A few\
Large makebox[1cm]{}overlapping\
makebox[3cm]{}lines.

color{cyan}Huge ..................................And another paragraph.
end{overlap}
Still more text.

end{document}


The corrseponding output:



Output of the second code sample



I’m not (yet) going to provide explanations, because it is still unclear whether or not this is what the OP is trying to achieve.







share|improve this answer














share|improve this answer



share|improve this answer








edited yesterday

























answered Jan 12 at 20:28









GuMGuM

16.2k2455




16.2k2455













  • That's exactly the effect I meant and is interesting. But when I changed a bit `makebox[1cm]{}Huge{overlapping}` it didn't work any more.

    – Max
    Jan 13 at 9:00











  • @Max: This is because Huge also changes baselineskip, lineskip lineskiplimit; it works if you use {Huge overlapping} because these changes are then undone before the paragraph ends. You may also want to have a look at this question about the usage of Huge and its ilk.

    – Circumscribe
    Jan 13 at 15:05



















  • That's exactly the effect I meant and is interesting. But when I changed a bit `makebox[1cm]{}Huge{overlapping}` it didn't work any more.

    – Max
    Jan 13 at 9:00











  • @Max: This is because Huge also changes baselineskip, lineskip lineskiplimit; it works if you use {Huge overlapping} because these changes are then undone before the paragraph ends. You may also want to have a look at this question about the usage of Huge and its ilk.

    – Circumscribe
    Jan 13 at 15:05

















That's exactly the effect I meant and is interesting. But when I changed a bit `makebox[1cm]{}Huge{overlapping}` it didn't work any more.

– Max
Jan 13 at 9:00





That's exactly the effect I meant and is interesting. But when I changed a bit `makebox[1cm]{}Huge{overlapping}` it didn't work any more.

– Max
Jan 13 at 9:00













@Max: This is because Huge also changes baselineskip, lineskip lineskiplimit; it works if you use {Huge overlapping} because these changes are then undone before the paragraph ends. You may also want to have a look at this question about the usage of Huge and its ilk.

– Circumscribe
Jan 13 at 15:05





@Max: This is because Huge also changes baselineskip, lineskip lineskiplimit; it works if you use {Huge overlapping} because these changes are then undone before the paragraph ends. You may also want to have a look at this question about the usage of Huge and its ilk.

– Circumscribe
Jan 13 at 15:05


















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%2f469659%2fhow-to-make-a-0pt-height-box%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 change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?