GeneralThat little space between two frameboxes

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
cvp
Posts: 11
Joined: Wed Jul 30, 2008 11:49 pm

That little space between two frameboxes

Post by cvp »

I didn't realize that space was so holy. I can't get rid of it.

My situation:
I have a framebox, a newline, and another framebox of a different width. I want to fudge that lower framebox up so that the top border of the bottom framebox is touching the bottom border of the top framebox, effectively forming a double-width border where they're in contact.
This seems like something too trivial to turn the entire thing into a tabular, and I figure, as usual, there's something obscure that I'm missing.

Extensive combinations of vspace, addvspace, \\, and raisebox have been tried. While those all work just fine to lower the bottom box, there is always that minimal amount of spacing between their borders when I try to move the bottom box up.

I'm frustrated enough at this point that I'm about to screencap, make that adjustment in mspaint, and then load it as a picture.
Please don't let me have to resort to this.

Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

That little space between two frameboxes

Post by Stefan Kottwitz »

Hi cvp,

you could use \vspace with negative space parameter, like

Code: Select all

\framebox[2cm]{text1}

\vspace{-3\fboxrule}
\framebox[2cm]{text2}
or similar just with appropriate space.

Stefan
LaTeX.org admin
cvp
Posts: 11
Joined: Wed Jul 30, 2008 11:49 pm

Re: That little space between two frameboxes

Post by cvp »

Stefan,

All of the previously mentioned commands (vspace, addvspace, raisebox) were tried with negative values, and none of them would allow the box to go any higher than 1mm below the previous box.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

That little space between two frameboxes

Post by Stefan Kottwitz »

Hi cvp,

it works for me. Try this example:

Code: Select all

\documentclass[a4paper,10pt]{article}
\begin{document}
\framebox[2cm]{Text1}

\vspace{-3\fboxrule}
\framebox[2cm]{Text2}
\end{document}
Raising the absolute value for \vspace raises the box. Do you get something different?

Stefan
LaTeX.org admin
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Re: That little space between two frameboxes

Post by Juanjo »

Why don't you post a minimal working example showing both boxes? It would be useful to see precisely what are you trying to do.

Edited: I sent this post without reading the preceding one by Stefan_K. Anyway, a MWE would help.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
cvp
Posts: 11
Joined: Wed Jul 30, 2008 11:49 pm

That little space between two frameboxes

Post by cvp »

Huh. Fascinating. That paragraph break is what lets it happen, apparently.
Try this:

Code: Select all

\documentclass[a4paper,10pt]{article}
\begin{document}
\noindent \framebox[2cm]{Text1}\\%
\vspace{-3\fboxrule}%
\framebox[2cm]{Text2}
\end{document}
You'll notice that no argument for \vspace will allow it to go higher than a certain amount if you simply use \\ (or \newline or \linebreak to get the next line.
You must have a new paragraph, it seems, in order to shrink that space at all. (I just tried \par, and that allows the space adjustment as I intended.)

Well, my code's going to look ugly as all hell, but at least this will do the trick. Hopefully no one will judge me for the contents of this cls file.
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

That little space between two frameboxes

Post by Juanjo »

cvp wrote:Huh. Fascinating. That paragraph break is what lets it happen, apparently.
Yes, it is, but it is not really necessary.
cvp wrote: You must have a new paragraph, it seems, in order to shrink that space at all. (I just tried \par, and that allows the space adjustment as I intended.)
No, you mustn't. Try this:

Code: Select all

\documentclass[a4paper,10pt]{article}
\begin{document}
\noindent \framebox[2cm]{Text1}
\vspace{-3\fboxrule}\hfill\mbox{} \\
\framebox[2cm]{Text2}
\end{document}
There is no new paragraph, just a new line in the same paragraph. The \vspace command acts as soon as the current line is filled.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
cvp
Posts: 11
Joined: Wed Jul 30, 2008 11:49 pm

That little space between two frameboxes

Post by cvp »

Sure, fine, it doesn't have to be a new paragraph.
It's just that

Code: Select all

\par
is easier to type and more understandable than

Code: Select all

\hfill\mbox{} \\
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

That little space between two frameboxes

Post by Juanjo »

The simplest way:

Code: Select all

\documentclass[a4paper,10pt]{article}
\begin{document}
\noindent \framebox[2cm]{Text1} \\[-3\fboxrule]
\framebox[2cm]{Text2}
\end{document}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Post Reply