2

I am using a minipage environment to display these tables. I want the top row of each table to align vertically (as opposed to right now where it looks like the first table is in the center vertically of the first). Thanks!

\begin{document} 
\begin{minipage}[t]{0.475\linewidth}
    \begin{tabular}{|l|l|}
        \hline
        \textsf{Monthly Income} & \textsf{\$5500} \\
        \hline
        \textsf{Other Income} & \textsf{\$150} \\
        \hline
        \textbf{\textsf{Total Income}} & \textbf{\textsf{\$5650}}\\
        \hline
    \end{tabular}
\end{minipage}
\hfill
\begin{minipage}[t]{0.475\linewidth}
    \begin{tabular}{|l|l|}
        \hline
         \textsf{Mortgage} & \textsf{\$2000}  \\
         \hline
         \textsf{Mortgage} & \textsf{\$2000}  \\
         \hline
         \textsf{Mortgage} & \textsf{\$2000}  \\
         \hline
         \textsf{Mortgage} & \textsf{\$2000}  \\
         \hline
         \textsf{Mortgage} & \textsf{\$2000}  \\
         \hline
         \textsf{Mortgage} & \textsf{\$2000}  \\
         \hline
    \end{tabular}

\end{minipage}
    \end{document}
3

3 Answers 3

3

As @DavidCarlisle has already pointed out in a comment, there's no need to encase the tabular environments in minipage environments. Instead, as @samcarter_is_at_topanswers.xyz has already suggested, just use the [t] vertical positioning specifier for both tabular environments.

I would suggest, additionally, that you place both tabular environments inside a center environment. This'll guarantee that the tables are separated vertically from the surrounding material. It'll also simplify the task of localizing directives, such as switching to \sffamily for both tables; making sans-serif the default obviates the need for all those \textsf wrappers.

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage{array}      % for '\extrarowheight' parameter
\usepackage{showframe}  % draw framelines around text block

\begin{document} 
\begin{center} % localize scope of next two instructions
\setlength\extrarowheight{2pt} % for a less-cramped look
\sffamily % make sans-serif the default

\begin{tabular}[t]{|l|l|}
   \hline
   Monthly Income & \$5500 \\
   \hline
   Other Income   & \$150 \\
   \hline
   \textbf{Total Income} & \textbf{\$5650}\\
   \hline
\end{tabular}
\hspace{1.5cm} % choose width to suit your needs
\begin{tabular}[t]{|l|l|}
    \hline
    Mortgage & \$2000  \\
    \hline
    Mortgage & \$2000  \\
    \hline
    Mortgage & \$2000  \\
    \hline
    Mortgage & \$2000  \\
    \hline
    Mortgage & \$2000  \\
    \hline
    Mortgage & \$2000  \\
    \hline
\end{tabular}
\end{center}

\end{document}
2

Your main problem is already solved by comments, so by following MWE is shown how you can write your tables with use of the tabularray and siunitx packages:

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}

\begin{document} 
\begin{table}[ht]
\sisetup{detect-all,   % <--
        table-format={\$},
        table-align-text-before=false
        }
\centering
    \begin{tblr}[t]{colspec={Q[l, font=\sffamily] 
                             Q[c,font=\sffamily,preto=\$, si]},
                    row{Z} = {font=\sffamily\bfseries},
                    hlines, vlines}
Monthly Income  &  5500     \\
Other Income    &   150     \\
Total Income    &  5650     \\
    \end{tblr}
\hfil
    \begin{tblr}[t]{colspec={Q[l, font=\sffamily] 
                             Q[c,font=\sffamily,preto=\$, si]},
                    hlines, vlines}
Mortgage    &    2000  \\
Mortgage    &    2000  \\
Mortgage    &    2000  \\
Mortgage    &    2000  \\
Mortgage    &    2000  \\
Mortgage    &    2000  \\
    \end{tblr}
\end{table}
\end{document}

Edit: With considering @Mico comments about correct use of the siunix package.

enter image description here

5
  • The Arabic numerals in both tables would appear to be serif rather than sans-serif. (Are the options font=\sffamily and si maybe in conflict?) Is my impression correct? If so, is there a way to use sans-serif for the numerals as well? E.g., do you think it might suffice to execute \sffamily before \sisetup and to change detect-weight to detect-all? A separate issue: Would you be wiling to change table-format={\$}4.2 to table-format={\$}4.0? There's no point in reserving space for nonexistent cents, is there?
    – Mico
    Commented Jul 10 at 9:31
  • @Mico, huh, you are right. I need to check my answer again ...
    – Zarko
    Commented Jul 10 at 9:57
  • @Mico, It looks that at writing of my answer a like that the "copy-past" gnome was nagging me ... Corrected now. Thank you very much.
    – Zarko
    Commented Jul 10 at 10:13
  • Thanks for making these changes. Incidentally, when you provide motivations for using tabularray such as "you can write your tables with shorter and more consistent code", are you hinting that some other person's LaTeX code is wordy and not fully consistent? :-)
    – Mico
    Commented Jul 10 at 10:35
  • 1
    @Mico, this was not my intention at all. I change my wording in my answer. Hopefully is now better.
    – Zarko
    Commented Jul 10 at 12:54
1

You don't need minipages, just the [t] option to tabular.

\documentclass{article}

\begin{document}

\begin{center}
\sffamily

\begin{tabular}[t]{|l|l|}
  \hline
  Monthly Income & \$5500 \\
  \hline
  Other Income & \$150 \\
  \hline
  \textbf{Total Income} & \textbf{\$5650}\\
  \hline
\end{tabular}\hfil
\begin{tabular}[t]{|l|l|}
  \hline
  Mortgage & \$2000  \\
  \hline
  Mortgage & \$2000  \\
  \hline
  Mortgage & \$2000  \\
  \hline
  Mortgage & \$2000  \\
  \hline
  Mortgage & \$2000  \\
  \hline
  Mortgage & \$2000  \\
  \hline
\end{tabular}
\end{center}

\end{document}

caged tables

With a different look:

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{center}
\sffamily

\begin{tabular}[t]{@{}lr@{}}
  \toprule
  Income & Amount (\$) \\
  \midrule
  Monthly & 5500 \\
  Other & 150 \\
  \midrule
  \textbf{Total} & \textbf{5650}\\
  \bottomrule
\end{tabular}\hfil
\begin{tabular}[t]{@{}lr@{}}
  \toprule
  Expenses & Amount (\$) \\
  \midrule
  Mortgage & 2000  \\
  Mortgage & 2000  \\
  Mortgage & 2000  \\
  Mortgage & 2000  \\
  Mortgage & 2000  \\
  Mortgage & 2000  \\
  \bottomrule
\end{tabular}
\end{center}

\end{document}

better tables

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .