3

I just dont know how to centering the text in multirow and multicolumn table. And how to put a line to te right of the table.

\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}
0

I assume, that you looking for this:

enter image description here

I first remove unnecesary \multicolumns (see code) and than add ˙ to \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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.