3

I need to fully justified the contents of table such as RSCA ,RR1 ,RR2 etc values. Is there any way to provide values in a table that is fully justified horizontally not the Left Aligned such as we provided \begin{tabular}{|l|l|l|} which left aligned the content.

The code is shown below:

\def\arraystretch{1.3}%
\begin{table}[h]
\centering
\caption{Values of Dispersion Constant ($R$)}
\begin{tabular}{|l|l|l|}
\hline
\multicolumn{1}{|c|}{\textbf{Algorithm}} & \multicolumn{2}{ c|}{{\boldmath\textbf{Dispersion Constant ($R$)}}}\\
\hline
& \multicolumn{1}{ c|}{\textbf{M=16}} & \multicolumn{1}{ c|}{\textbf{M=32}}\\ \hline 
SCA & R\textsubscript{SCA} = 123 & R\textsubscript{SCA} = 123 \\\hline
\justifying
MCMA & R\textsubscript{R} = 2.55 and R\textsubscript{I} = 2.55  & R\textsubscript{R} = 2.55 and R\textsubscript{I} = 2.55\\
\hline 
\multirow{2}*{DD-MCMA} & R\textsubscript{R1} = 0.75 and R\textsubscript{R2} = 2.55 & R\textsubscript{R1} = 0.75 and R\textsubscript{R2} = 2.55 \\
& R\textsubscript{I1} = 0.75 and R\textsubscript{I2} = 2.55 & R\textsubscript{I1} = 0.75 and R\textsubscript{I2} = 2.55 \\
\hline
\end{tabular}
\end{table}

I want to make the this part of code to appear Justified Aligned Horizontally

SCA & R\textsubscript{SCA} = 123 & R\textsubscript{SCA} = 123 \\\hline
\justifying
MCMA & R\textsubscript{R} = 2.55 and R\textsubscript{I} = 2.55  & 
R\textsubscript{R} = 2.55 and R\textsubscript{I} = 2.55\\
\hline 
\multirow{2}*{DD-MCMA} & R\textsubscript{R1} = 0.75 and R\textsubscript{R2} 
= 2.55 & R\textsubscript{R1} = 0.75 and R\textsubscript{R2} = 2.55 \\
& R\textsubscript{I1} = 0.75 and R\textsubscript{I2} = 2.55 & 
R\textsubscript{I1} = 0.75 and R\textsubscript{I2} = 2.55 \\
\hline

1 Answers1

5

Edit 1 (reply to the comment):

Explanation of the column types (code after tabular):

  1. with >{...} you can tell LaTeX to do something before writing the cell content, with <{...} something after; you need array package for these options
  2. with S[table-format=1.2] you tell LaTeX you have numbers with 1 integer and 2 decimal to be aligned at the decimal point (package siunitx is needed)
  3. with @{something} you can insert something instead of the inter-column space (array package)
  4. with !{something} you can insert something instead of the | (always see array package).

\documentclass{article}
\usepackage{array}
\renewcommand{\arraystretch}{1.3}
\usepackage{siunitx}
\usepackage{caption}
\usepackage{amsmath}

\begin{document}
    \begin{table}[h]
        \centering\footnotesize
        \caption{Values of Dispersion Constant ($R$)}
        \begin{tabular}{
                |l|
                >{$}l<{$}@{${}={}$}S[table-format=1.2]
                !{and}
                >{$}l<{$}@{${}={}$}S[table-format=1.2]|
                >{$}l<{$}@{${}={}$}S[table-format=1.2]
                !{and}
                >{$}l<{$}@{${}={}$}S[table-format=1.2]|
            }
            \hline
            \multicolumn{1}{|c|}{\textbf{Algorithm}} & \multicolumn{8}{ c|}{{\boldmath\textbf{Dispersion Constant ($R$)}}}\\
            \hline
            & \multicolumn{4}{ c|}{\boldmath $M=16$} & \multicolumn{4}{ c|}{\boldmath $M=32$}\\ \hline 
            SCA & \multicolumn{4}{c|}{$R_{\text{SCA}}=123$} & \multicolumn{4}{c|}{$R_{\text{SCA}}=123$} \\\hline
            MCMA & R_{\text{R}} & 2.55 & R_{\text{I}} & 2.55  & R_{\text{R}} & 2.55 & R_{\text{I}} & 2.55\\
            \hline 
            DD-MCMA & R_\text{{R1}} & 0.75 & R_{\text{R2}} & 2.55 & R_{\text{R1}} & 0.75 & R_{\text{R2}} & 2.55 \\
            & R_{\text{I1}} & 0.75 & R_{\text{I2}} & 2.55 & R_{\text{I1}} & 0.75 & R_{\text{I2}} & 2.55 \\
            \hline
        \end{tabular}
    \end{table}
\end{document}

enter image description here

Edit 2 (this is what the OP want, not what I like):

If you want the Word alignment, use \hfill:

\documentclass{article}
\usepackage{array}
\usepackage{siunitx}
\usepackage{caption}
\usepackage{amsmath}
\usepackage{multirow}

\begin{document}
\def\arraystretch{1.3}%
\begin{table}[h]
    \centering
    \caption{Values of Dispersion Constant ($R$)}
    \begin{tabular}{|l|l|l|}
        \hline
        \multicolumn{1}{|c|}{\textbf{Algorithm}} & \multicolumn{2}{ c|}{{\boldmath\textbf{Dispersion Constant ($R$)}}}\\
        \hline
        & \multicolumn{1}{ c|}{\textbf{M=16}} & \multicolumn{1}{ c|}{\textbf{M=32}}\\ \hline 
        SCA & R\textsubscript{SCA} \hfill = \hfill 123 & R\textsubscript{SCA} \hfill = \hfill 123 \\\hline
        MCMA & R\textsubscript{R} \hfill = \hfill 2.55 \hfill and R\textsubscript{I} \hfill = \hfill 2.55  & R\textsubscript{R} \hfill = 2.55 \hfill and \hfill R\textsubscript{I} \hfill = \hfill 2.55\\
        \hline 
        \multirow{2}*{DD-MCMA} & R\textsubscript{R1} \hfill = \hfill 0.75 \hfill and \hfill R\textsubscript{R2} \hfill = \hfill 2.55 & R\textsubscript{R1} \hfill = \hfill 0.75 \hfill and \hfill R\textsubscript{R2} \hfill = \hfill 2.55 \\
        & R\textsubscript{I1} \hfill = \hfill 0.75 \hfill and \hfill R\textsubscript{I2} \hfill = \hfill 2.55 & R\textsubscript{I1} \hfill = 0.75 \hfill and \hfill R\textsubscript{I2} \hfill = \hfill 2.55 \\
        \hline
    \end{tabular}
\end{table}
\end{document}

enter image description here

CarLaTeX
  • 62,716