Latex: minipage for list and table side-by-side

In summary, the conversation discusses the use of minipage and the issue of extra space appearing on top of a table. The expert suggests understanding how TeX builds a page from "boxes and glue" and adjusting the baseline position with the [b] [m] or [t] options of the minipage. The expert also suggests using \vspace*{-10pt} or nesting tabular environments to solve the issue.
  • #1
gsal
1,065
54
Say, I am trying to learn how to use minipage but there is some space on top of the table that seems to be coming from nowhere...any idea what might be going on? The huge space is still there even when I remove vspace 10pt, besides, 10pt is not that much...anyway.

thanks,

gsal

Code:
\begin{minipage}[b]{0.58\textwidth}
\begin{itemize}
\item Blower flow=1.951 $kg/s$ and uses profiles from equivalent blower model for velocities, temperatures, and turbulence quantities.  The resulting static pressure plus axial velocity head is 4599$Pa$.
\item Vent scoop flow=0.145 $kg/s$ at Tt=334.8$K$.
\item Rotor flow=0.45327 $kg/s$.
\item Static pressure in endbox=3848.7 $Pa$.
\item For stator finger and stator exhaust vents Ps=1051 $Pa$ (the value reported back is 1049.94).
\item For stator intake vents Pt=3741.92 $Pa$.
\item Sector angle for model is 20 deg.
\end{itemize}  
\vspace*{10pt}
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[b]{0.15\textwidth}
\begin{tabular}{|p{1.5cm}|p{2cm}|p{1.cm}|}
\hline
Rotor Vent No. & Radial mass flow ($kg/s$) & Tt ($K$) \\
\hline
1	& 0.014816	& 332.4 \\
2	& 0.014453	& 332.2 \\
3	& 0.013824	& 332.1 \\
4	& 0.013304	& 332.0 \\
5	& 0.012819	& 332.0 \\
6	& 0.012415	& 331.9 \\
7	& 0.012082	& 331.9 \\
8	& 0.011662	& 331.9 \\
9	& 0.011328	& 331.9 \\
10	& 0.011072	& 331.8 \\
11	& 0.010860	& 331.8 \\
12	& 0.010585	& 331.7 \\
13	& 0.010406	& 331.7 \\
14	& 0.010309	& 331.7 \\
15	& 0.010318	& 331.7 \\
16	& 0.010284	& 331.8 \\
17	& 0.010206	& 331.8 \\
18	& 0.010210	& 331.8 \\
19	& 0.010255	& 331.8 \\
20	& 0.010340	& 331.7 \\
21	& 0.010465	& 331.7 \\
22	& 0.010622	& 331.6 \\
23	& 0.010808	& 331.5 \\
24	& 0.010961	& 331.4 \\
25	& 0.011113	& 331.3 \\
26	& 0.011271	& 331.2 \\
27	& 0.011430	& 331.1 \\
\hline
\end{tabular}
\end{minipage}
 

Attachments

  • minipage.png
    minipage.png
    30.9 KB · Views: 2,045
Physics news on Phys.org
  • #2
You need to understand how TeX builds a page from "boxes and glue".

For normal text, you don't need to bother much about that, because each letter in the font is enclosed by a box that is the right size and shape to fit together properly.

But effectively, you have a "line of text" consisting of a minipage, some space (\hspace), and another minipage. TeX treats each minipage as a single "box" when it is figuring out how to build the line.

Every box has a "baseline position" and TeX adjusts their vertical positions so the baselines match up.

You can set where the baseline is relative to the box with the [m] or [t] options of the minipage. These set the baseline to the bottom, middle, or top of the minipage. Probably you want both to be [t] or both [m], but play around with all the options to see what is going on.

While playing, replace the \hspace between the minipages by a bit of ordinary text, so you can see where TeX is putting the baseline of the complete line.

Your \vspace* inside the first minipage seems like a bad move, because it adds space to the bottom of the minipage and make the alignment even worse. A bigger amount of \vspace at the end of the second minipage might be a different way to fix the problem.
 
  • #3
Thanks for the hints, they did help, including adding ordinary text to see how the minipages alignment relate to the line.

As you may have noticed, though, the second minipage contains a 'tabular' environment...I removed the table, put ordinary text, played around with widths and alignments and it seems to me that the "tabular" environment does not quite honor the minipage alignment option...the table seems to always be vertically centered with the line...

...is this clear? and most importantly...does it make sense to you?
 
  • #4
Hm... I played around with your code before I made the post, and I didn't see anything strange from the tabular environment (nor did I expect to).

IIRC "tabular" also has an option to set its top/middle/bottom position, but that should be irrelevant because there is nothing else inside the minipage, and the tabular environment shouldn't leak "outside" the minipage whatever happens.

Try putting \hrule at the top and bottom of your minipages, to see where the space is coming from.

It's possible that "itemize" is adding some white space at the top and bottom, not "tabular".

If all else fails, "negative spaces" like \vspace*{-10pt} are legal.

Or, you could try something like
Code:
begin{tabular}{@{}p{0.58\textwidth)@{\hspace{0.5cm}}p{0.15\textwidth}@{}}
\begin{itemize}
... 
\end{itemize} &
{\begin{tabular}
...
\end{tabular}}
\end{tabular}

You can nest tabular environments, but note the extra pair of { } around the nested one. Mostly I use an document class that has its own version of the tabular environments, and I can't remember if the extra { } are needed with the "standard" tabular, but they won't do any harm.
 
  • #5
Oh, just re-read your post and noticed the full contents of it...yes, I ended up "fixing" the problem by increasing vspace in the first minipage...in my case, the table is taller than my text, so...

thanks.
 
  • #6
gsal said:
in my case, the table is taller than my text, so...

I noticed that as well. Plus, your OP didn't say exactly what you wanted the document to look like :smile:
 
  • #7
It looks like I started my 12:30 post before seeing your 12:24...so, my answer still refers to your 9:49 post.

What I had tried was "table" and then the "minipages" inside of it and it did not make a difference...but I should give a try to your latest suggestion with "tabular" and see if things line up out of the box without having to play around with vspace.

Thanks again.
 
  • #8
o.k., I checked. The outer "tabular" approach works better and honors the inner "tabular" request for top vertical alignment...no need for minipage and playing around with vspace.

Thanks, again.
 

1. What is a minipage in Latex?

A minipage in Latex is a type of environment that allows you to place content in a specific area of your document. It is commonly used to create side-by-side elements such as lists and tables.

2. How do I use a minipage to create a list and table side-by-side?

To use a minipage for a list and table side-by-side, you first need to define the width of each element within the minipage. Then, you can use the \begin{minipage} and \end{minipage} commands to enclose the list and table code respectively. Make sure to add a \vfill command between the two elements to ensure proper spacing.

3. Can I adjust the vertical alignment of elements within a minipage?

Yes, you can adjust the vertical alignment of elements within a minipage by using the \begin{minipage}[position] command, where position can be either t (top), b (bottom), or c (center). This will align the content of the minipage according to the specified position.

4. Is it possible to have multiple minipages in a single document?

Yes, it is possible to have multiple minipages in a single document. However, it is important to note that minipages are fixed in size and cannot break across pages. If you have multiple minipages, make sure they can fit on the same page or consider using the \newpage command to start a new page.

5. What are some advantages of using minipages in Latex?

Minipages in Latex offer several advantages, including the ability to create side-by-side elements, specify custom widths and alignments, and control the placement of content within a document. They are also useful for creating complex layouts and designs in a precise manner.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
46K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • Linear and Abstract Algebra
Replies
4
Views
3K
Back
Top