Graphics, Figures & Tablesaligning framed boxes

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ssepman
Posts: 2
Joined: Mon Apr 05, 2010 6:17 pm

aligning framed boxes

Post by ssepman »

Greetings!

I can't seem to get the formatting right.
I want the side boarders of the inner boxes exactly overlap with the
borders of the outer box and still overlap in the middle as they do
now.
I also want the upper border of the box containing "aaa aaa..." to
exactly overlap with the surrounding box withouth having to specify
any numerical lengths.

Here's the result so far: http://kom.aau.dk/~ssepman/AAA.png
I've zoomed in with the PostScript viewer to better show the flaws.

Additional questions:
Is there a command, which gives you the length from current position
to the right border of the current box/environment?
Why does \vspace{20mm} have no effect in current context?
Even if we removed \vspace{20mm} command, we'd have the same vertical
gap between the horizontal line and the big box. Why? How to get rid
of it?

Code: Select all

\documentclass{article}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
\setlength{\fboxsep}{0in}
\begin{document}
\framebox[\textwidth]{\hrulefill}
\vspace{20mm}
\framebox[\textwidth]
{%
       \fbox{\begin{minipage}[t]{0.5\textwidth}
               AAA AAA AAA AAA AAA AAA AAA AAA AAA AAA AAA.
       \par
               AAA AAA AAA AAA AAA AAA AAA AAA AAA AAA AAA.
       \end{minipage}}%
%
       \fbox{\begin{minipage}[t]{0.5\textwidth}
               aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa.
       \end{minipage}}%
}%
\end{document}
Best Regards,
-Siim

Recommended reading 2024:

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

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

daleif
Posts: 199
Joined: Wed Nov 19, 2008 12:46 am

Re: aligning framed boxes

Post by daleif »

try adding a \strut at either end of the text

(there is also a Danish speaking meadi via the DK-TUG mailing list)
ssepman
Posts: 2
Joined: Mon Apr 05, 2010 6:17 pm

aligning framed boxes

Post by ssepman »

daleif wrote:try adding a \strut at either end of the text
Thanks for \strut ! It solved the vertical misalignment problem (although I haven't figured out exactly how).

Using the 'calc' package also simplified the alignment of left and right borders so it would precisely fit \textwidth.

There is still problem with the gap between the first and second \frameboxes. Namely, formatting depends on content, and I would NOT like the contents of the boxes influence how they are positioned in relation to each other.

Related phenomena:
a) When the contents of the first \framebox is "asdfghjkl", then there is shorter distance between this and the next box. If the contents is "\hrulefill", then the distance is greater.
b) The contents of second \framebox influence the gap between first \framebox and second \framebox. That is, when \fboxrule (the thickness of the frame) is set to be around 0.7pt, then there is NO GAP between first \framebox and second \framebox. If the value is less or greater than that, a gap will appear. The size of the gap is dependant on \fboxrule, but in an obscure way: the gap is more or less the same for 1pt and 10pt frame thicknesses, but the dependance on \fboxrule is more linear when I tested sub-0.7pt values.

Code: Select all

\documentclass{article}
\usepackage{calc}

\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
\setlength{\fboxsep}{0pt}

\begin{document}
\framebox[\textwidth]{asdfghjkl}
%\vskip20mm% when uncommented, this really makes gap +20mm wider
\framebox[\textwidth]
{%
	\setlength{\fboxrule}{1pt}%
	\fbox{\begin{minipage}[t]{\textwidth /2 -\fboxrule*2}
		\strut%
		AAA AAA AAA AAA AAA AAA AAA AAA AAA AAA AAA.
	\par
		AAA AAA AAA AAA AAA AAA AAA AAA AAA AAA AAA.
	\end{minipage}}%
%
	\fbox{\begin{minipage}[t]{\textwidth /2 -\fboxrule*2}
		\strut%
		aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa.
	\end{minipage}}%
}%
\end{document}
xdvik dvi viewer output with given code

I thought LaTeX is less mysterious than a typical WYSIWYG text processor. What's the deal?

Best Regards,
-Siim
daleif wrote:(there is also a Danish speaking meadi via the DK-TUG mailing list)
Unfortunately, that wouldn't be a more efficient opportunity to exchange thoughts (I think), because that would involve a lot of translate.google.com and possibly the related "lost in translation" phenomenon. I'm actually a guest student and I'm not too good at danish :)
Post Reply