我只是不知道如何将多行多列表格中的文本居中。以及如何在表格右侧添加一条线。
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{multirow}
\usepackage[utf8]{inputenc}
\usepackage{pdfpages}
%\usepackage{lmodern}
\usepackage{txfonts} %Times New Roman
\usepackage[T1]{fontenc}
\usepackage[english,slovak]{babel}
\makeatletter
\begingroup
\toks0=\expandafter{\@cline{#1}-{#2}\@nil}
\@ifpackageloaded{booktabs}{%
\toks2=\expandafter{\@@@cmidrule[{#1}-{#2}]{#3}{#4}}%
}{}
\catcode`-=\active
\edef\x{\gdef\unexpanded{\@cline#1-#2\@nil}{\the\toks0}}\x
\@ifpackageloaded{booktabs}{%
\edef\x{\gdef\unexpanded{\@@@cmidrule[#1-#2]#3#4}{\the\toks2}}\x
}{}
\endgroup
\makeatother
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{|c|c|c|}
\hline
\multirow{2}{*}{Panda} & \multicolumn{2}{l}{Tiger} \\ \cline{2-3}
& \multicolumn{1}{l}{aaaaaa} & \multicolumn{1} {l}{bbbbb} \\
\hline
kdsjfk & kasjdf &kjadsf \\
kdsjfk & kasjdf &kjadsf \\
kdsjfk & kasjdf &kjadsf \\
kdsjfk & kasjdf &kjadsf \\
\hline
\end{tabular}
\caption{xxx}
\label{tab:xxx}
\end{table}
\end{document}
答案1
我假设你正在寻找这个:
我首先删除不必要的部分\multicolumns
(参见代码),然后将˙添加|˙
到\multicolumn{2}{c|}{Tiger}
...
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{txfonts} %Times New Roman
\usepackage[T1]{fontenc}
\usepackage[english,slovak]{babel}
\makeatletter
\begingroup
\toks0=\expandafter{\@cline{#1}-{#2}\@nil}
\@ifpackageloaded{booktabs}{%
\toks2=\expandafter{\@@@cmidrule[{#1}-{#2}]{#3}{#4}}%
}{}
\catcode`-=\active
\edef\x{\gdef\unexpanded{\@cline#1-#2\@nil}{\the\toks0}}\x
\@ifpackageloaded{booktabs}{%
\edef\x{\gdef\unexpanded{\@@@cmidrule[#1-#2]#3#4}{\the\toks2}}\x
}{}
\endgroup
\makeatother
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{|c|c|c|}
\hline
\multirow{2}{*}{Panda}
& \multicolumn{2}{c|}{Tiger} \\
\cline{2-3}
& aaaaaa & bbbbb \\
\hline
kdsjfk & kasjdf &kjadsf \\
kdsjfk & kasjdf &kjadsf \\
kdsjfk & kasjdf &kjadsf \\
kdsjfk & kasjdf &kjadsf \\
\hline
\end{tabular}
\caption{xxx}
\label{tab:xxx}
\end{table}
\end{document}