1

I have generated the following table:

\documentclass{article}
%\usepackage[utf8]{inputenc}
%\usepackage{array}
%\usepackage{wrapfig}
%\usepackage{multirow}
\usepackage{tabularx}


\begin{document}

\begin{tabularx}{0.8\textwidth} { | >{\raggedright\arraybackslash}X | >{\centering\arraybackslash}X | >{\raggedleft\arraybackslash}X | }
   \hline
   T & F & T \\
   \hline
   T &  F & T \\
   \hline
   F & T & F \\
   \hline
\end{tabularx}




\end{document}

I would like to add i,j, k, and B just as in the picture below and I would like to reduce the space between columns (so that the table appears as in the picture) but do not know how to do this:

enter image description here

What must I do to align text both above and next to, the table, and reduce the space between the columns?

2 Answers 2

1

With {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

B\hspace{2cm}
\begin{NiceTabular}[hvlines,first-row,first-col,baseline=0]{ccc}
    & $i$ & $j$ & $k$ \\
$i$ & T   & F   & T \\
$j$ & T   & F   & T \\
$k$ & F   & T   & F \\
\end{NiceTabular}

\end{document}

Output of the above code

0

A very simple simple approach would be

\documentclass{article}
%\usepackage[utf8]{inputenc}
\usepackage{array}
%\usepackage{wrapfig}
%\usepackage{multirow}
%\usepackage{tabularx}
%\usepackage[table]{xcolor}
%\usepackage{bigstrut}


\renewcommand{\arraystretch}{1.5}
\begin{document}

B   \hspace{30pt}
\begin{tabular}[t]{c|c|c|c|}
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{i} & \multicolumn{1}{c}{j} & \multicolumn{1}{c}{k} \\
    \cline{2-4}i     & T     & F     & T \\
    \cline{2-4}j     & T     & F     & T \\
    \cline{2-4}k     & F     & T     & F \\
    \cline{2-4}
\end{tabular}

out3

or for a finer control

    \documentclass{article}
    %\usepackage[utf8]{inputenc}
    %\usepackage{array}
    %\usepackage{wrapfig}
    %\usepackage{multirow}
    \usepackage{tabularx}
        
    \usepackage{makecell}   
    \setcellgapes{7pt}
    
    \begin{document}
    
    B
    
    \vspace{-1.2\baselineskip} % vertical offset
    { \hspace{40pt} % horizontal offset
        \makegapedcells
         \begin{tabular}{c|c|c|c|}
        \multicolumn{1}{c}{} & \multicolumn{1}{c}{i} & \multicolumn{1}{c}{j} & \multicolumn{1}{c}{k} \\[-3pt] % control the space between i j k and table
        \cline{2-4}i     & T     & F     & T \\
        \cline{2-4}j     & T     & F     & T \\
        \cline{2-4}k     & F     & T     & F \\
        \cline{2-4}
    \end{tabular}}  

    \end{document}

out2

1
  • I agree with the general idea but please use the [t] optional parameter of tabular instead of \vspace{-\baselineskip}.
    – campa
    Dec 4, 2020 at 12:38

You must log in to answer this question.

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