Search code examples
latextabularpdflatex

How to add index outside a table in latex


How to add index outside a table like this?

pic

Thanks!


Solution

  • Going out on a limb here, I assume you want to create the indeces in the smaller font size...
    I extended the table and reduzed the font size for the indeces. Using the array package for the rest.

    Minimal working the solution:

    \documentclass{article}
    \usepackage{array}
    
    \begin{document}
    
    \begin{table}
    \centering
    \begin{tabular}{ccccc}
                    & {\scriptsize 1}          & {\scriptsize 2}       & {\scriptsize 3}         & {\scriptsize 4}         \\ \cline{2-5}
    {\scriptsize 1} &  \multicolumn{1}{|c|}{0} &\multicolumn{1}{|c|}{ }& \multicolumn{1}{|c|}{-2}& \multicolumn{1}{|c|}{ } \\ \cline{2-5}
    {\scriptsize 2} &  \multicolumn{1}{|c|}{ } &\multicolumn{1}{|c|}{0}& \multicolumn{1}{|c|}{ } & \multicolumn{1}{|c|}{ } \\ \cline{2-5}
    {\scriptsize 3} &  \multicolumn{1}{|c|}{ } &\multicolumn{1}{|c|}{ }& \multicolumn{1}{|c|}{0} & \multicolumn{1}{|c|}{ } \\ \cline{2-5}
    {\scriptsize 4} &  \multicolumn{1}{|c|}{ } &\multicolumn{1}{|c|}{ }& \multicolumn{1}{|c|}{ } & \multicolumn{1}{|c|}{0} \\ \cline{2-5}
    \end{tabular}
    \end{table}
    
    \end{document}
    

    With the following result:
    enter image description here

    You can choose a different font size for the indices, like \small, \footnotesize or \tiny.