[英]How to add index outside a table in latex
How to add index outside a table like this?如何在这样的表之外添加索引?
Thanks!谢谢!
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:结果如下:
You can choose a different font size for the indices, like \small
, \footnotesize
or \tiny
.您可以为索引选择不同的字体大小,例如\small
、 \footnotesize
或\tiny
。
A basic version trying to reduce the number of multicolumn
s used may be:尝试减少使用的multicolumn
数量的基本版本可能是:
\documentclass{article}
\begin{document}
\begin{tabular}{*{5}{c|}}
\multicolumn{1}{c}{ } & \multicolumn{1}{c}{1} & \multicolumn{1}{c}{2} & \multicolumn{1}{c}{3} & \multicolumn{1}{c}{4}\\\cline{2-5}
1 & 0 & & -2 & \\\cline{2-5}
2 & & 0 & & \\\cline{2-5}
3 & & & 0 & \\\cline{2-5}
4 & & & & 0 \\\cline{2-5}
\end{tabular}
\end{document}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.