4
\begin{document}
%first table
\renewcommand{\arraystretch}{1.1}
\centering
  \begin{tabular}{r l l}
  \hline \hline 
    \rowcolor[RGB]{77,77,77}\color {white}BAZA & \color{white}BROJNI SISTEM & \color {white}CIFRE \\ \hline \hline
  \rowcolor[RGB]{255,255,255} 2 &  Binarni C & 0,1 \\
  \rowcolor[RGB]{242,242,242} 3 &  Ternarni & 0,1,2 \\
  \rowcolor[RGB]{255,255,255} 5 &  Kvinarni & 0,1,...,4 \\
  \rowcolor[RGB]{242,242,242} 8 &  Oktalni & 0,1,...,7 \\
  \rowcolor[RGB]{255,255,255} 10  & Dekadski & 0,1,...,9 \\
 \rowcolor[RGB]{242,242,242} 12 & Duodekadni & o,1,...,9,$\alpha,\beta$ \\
  \rowcolor[RGB]{255,255,255} 16 &  Heksadecimalni & 0,1,...,9,A,...,F \\\hline \hline
  \end{tabular}\\
%2nd table
\renewcommand{\arraystretch}{1.1}
\centering
\begin{tabular}{|l|c|r|}
  \hline \hline
    \cellcolor[RGB]{204,255,204}L1 & L2 & L3 \\ \hline 
 \multirow{2}{*}{MR2} & \multicolumn{2}{c|}{MC2} \\ \cline{2-2} & D & \cellcolor[RGB]{255,230,204}E \\ \hline
  G & \cellcolor[RGB]{255,204,204}E & M \\ \hline
  \multicolumn{2}{|c|}{\cellcolor[RGB]{204,204,255}MC1} & \multirow{2}{*}{MR1}  \\ \cline{1-2}
  A & B &  \\\hline \hline
  \end{tabular}\\
\end{document}

How can I align these two tables vertically like these in pictures 2

1
  • With two minipages. And you may provide a complete MWE to let everyone copy/paste ans test your code.
    – SebGlav
    Commented Apr 12, 2021 at 13:17

3 Answers 3

6

You need two minipages inside a table environment.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[bosnian]{babel}

\usepackage[table]{xcolor}
\usepackage{multirow}

\begin{document}
%first table

\begin{table}[htp]
\renewcommand{\arraystretch}{1.1}

\begin{minipage}{0.65\textwidth}
\centering

\begin{tabular}{r l l}
\hline \hline 
\rowcolor[RGB]{77,77,77}
\color{white}BAZA &
\color{white}BROJNI SISTEM &
\color {white}CIFRE \\
\hline \hline
\rowcolor[RGB]{255,255,255} 2 &  Binarni C & 0,1 \\
\rowcolor[RGB]{242,242,242} 3 &  Ternarni & 0,1,2 \\
\rowcolor[RGB]{255,255,255} 5 &  Kvinarni & 0,1,\dots,4 \\
\rowcolor[RGB]{242,242,242} 8 &  Oktalni & 0,1,\dots,7 \\
\rowcolor[RGB]{255,255,255} 10  & Dekadski & 0,1,\dots,9 \\
\rowcolor[RGB]{242,242,242} 12 & Duodekadni & o,1,\dots,9,$\alpha,\beta$ \\
\rowcolor[RGB]{255,255,255} 16 &  Heksadecimalni & 0,1,\dots,9,A,\dots,F \\
\hline \hline
\end{tabular}

\caption{Pozicioni brojni sistem}
\end{minipage}%
\hfill
\begin{minipage}{0.35\textwidth}
\centering

\begin{tabular}{|l|c|r|}
\hline \hline
\cellcolor[RGB]{204,255,204}L1 & L2 & L3 \\
\hline 
\multirow{2}{*}{MR2} &
\multicolumn{2}{c|}{MC2} \\
\cline{2-2}
& D & \cellcolor[RGB]{255,230,204}E \\
\hline
G & \cellcolor[RGB]{255,204,204}E & M \\
\hline
\multicolumn{2}{|c|}{\cellcolor[RGB]{204,204,255}MC1} & \multirow{2}{*}{MR1}  \\
\cline{1-2}
A & B & \\
\hline \hline
\end{tabular}

\caption{Spajanje ćelija}
\end{minipage}

\end{table}

\end{document}

enter image description here

4

This answer is the same as egreg's answer but I wanted to show that, with {NiceTabular} of nicematrix, you will have a better output for the tabulars in the PDF viewers (you won't see thin white lines in the first tabular and some rules won't seem to vanish in the second tabular).

\documentclass{book}
\usepackage[left=3cm,right=3cm]{geometry}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{nicematrix}
\usepackage{float}

\begin{document}

\lipsum[1]

\begin{table}[htp]
\renewcommand{\arraystretch}{1.1}
\begin{minipage}{0.5\textwidth}
\centering
\begin{tabular}{@{}c@{}}
    \hline\noalign{\vspace{\dimexpr\doublerulesep-\arrayrulewidth}}
    \begin{NiceTabular}{rll}
    \CodeBefore
      \rowcolor[RGB]{77,77,77}{1}
      \rowcolors[RGB]{2}{242,242,242}{}
    \Body
    \hline 
    \color{white}BAZA & \color{white}BROJNI SISTEM & \color{white}CIFRE \\ \hline \hline
    2 &  Binarni C & 0,1 \\
    3 &  Ternarni & 0,1,2 \\
    5 &  Kvinarni & 0,1,...,4 \\
    8 &  Oktalni & 0,1,...,7 \\
    10  & Dekadski & 0,1,...,9 \\
    12 & Duodekadni & 0,1,...,9,$\alpha,\beta$ \\
    16 &  Heksadecimalni & 0,1,...,9,A,...,F \\
    \hline 
    \end{NiceTabular} \\ \noalign{\vspace{\dimexpr\doublerulesep-\arrayrulewidth}}
    \hline
\end{tabular}
\caption{Pozicioni bronji}
\end{minipage}\ignorespaces\hspace{12pt}\ignorespaces
%2nd table
\begin{minipage}[t]{0.5\textwidth}
\centering
\begin{tabular}{@{}c@{}}
    \hline\noalign{\vspace{\dimexpr\doublerulesep-\arrayrulewidth}}
    \begin{NiceTabular}{lcr}[colortbl-like,hvlines]
    \cellcolor[RGB]{204,255,204}L1 & L2 & L3 \\ 
    \Block{2-1}{MR2} & \Block{1-2}{MC2} \\ 
    & D & \cellcolor[RGB]{255,230,204}E \\ 
    G & \cellcolor[RGB]{255,204,204}E & M \\ 
    \Block[fill=[RGB]{204,204,255}]{1-2}{MC1} & & \Block{2-1}{MR1}  \\ 
    A & B &  \\
    \end{NiceTabular} \\
    \hline
\end{tabular}
\caption{Spajanje deijia}
\end{minipage}
\end{table}
\end{document}

Output of the above code

3

Hope this will helps you:

\documentclass{book}
\usepackage{xcolor}
\usepackage{multirow,colortbl}
\usepackage{float}
\begin{document}
%first table
\begin{minipage}[t]{0.65\textwidth}
\begin{table}[H]
\renewcommand{\arraystretch}{1.1}
\centering
  \begin{tabular}{r l l}
  \hline \hline 
    \rowcolor[RGB]{77,77,77}\color {white}BAZA & \color{white}BROJNI SISTEM & \color {white}CIFRE \\ \hline \hline
  \rowcolor[RGB]{255,255,255} 2 &  Binarni C & 0,1 \\
  \rowcolor[RGB]{242,242,242} 3 &  Ternarni & 0,1,2 \\
  \rowcolor[RGB]{255,255,255} 5 &  Kvinarni & 0,1,...,4 \\
  \rowcolor[RGB]{242,242,242} 8 &  Oktalni & 0,1,...,7 \\
  \rowcolor[RGB]{255,255,255} 10  & Dekadski & 0,1,...,9 \\
 \rowcolor[RGB]{242,242,242} 12 & Duodekadni & o,1,...,9,$\alpha,\beta$ \\
  \rowcolor[RGB]{255,255,255} 16 &  Heksadecimalni & 0,1,...,9,A,...,F \\\hline \hline
  \end{tabular}
\caption{Pozicioni bronji}
\end{table}
\end{minipage}\ignorespaces\hspace{12pt}\ignorespaces
%2nd table
\begin{minipage}[t]{0.35\textwidth}
\begin{table}[H]
\renewcommand{\arraystretch}{1.1}
\centering
\begin{tabular}{|l|c|r|}
  \hline \hline
    \cellcolor[RGB]{204,255,204}L1 & L2 & L3 \\ \hline 
 \multirow{2}{*}{MR2} & \multicolumn{2}{c|}{MC2} \\ \cline{2-2} & D & \cellcolor[RGB]{255,230,204}E \\ \hline
  G & \cellcolor[RGB]{255,204,204}E & M \\ \hline
  \multicolumn{2}{|c|}{\cellcolor[RGB]{204,204,255}MC1} & \multirow{2}{*}{MR1}  \\ \cline{1-2}
  A & B &  \\\hline \hline
  \end{tabular}
\caption{Spajanje deijia}
\end{table}
\end{minipage}
\end{document}

As you are not mentioning any class file name, I'm using the standard one....

You must log in to answer this question.