表格中的所有内容垂直居中,第一行第一列水平居中

表格中的所有内容垂直居中,第一行第一列水平居中
\documentclass[a4paper,oneside,11pt]{book}
\usepackage[left=4cm,right=3cm,top=4cm,bottom=3cm]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\begin{document}
    \begin{table}[h!]
        \centering
        \caption{Tabel dari t-norm dan t-conorm}
        \resizebox{\textwidth}{!}{
            \renewcommand{\arraystretch}{1.5}
            \begin{tabular}{|p{2cm}|c|c|}
                \hline
                Nama&t-norm&t-conorm\\
                \hline
                Standar&$T_m(x,y)=\min(x,y)$&$C_m(x,y)=\max(x,y)$\\
                \hline
                Jumlah terbatas&$T_b(x,y)=\max(0,x+y-1)$&$C_b(x,y)=\min(1,x+y)$\\
                \hline
                Hasil kali/ jumlah aljabar&$T_p(x,y)=xy$&$C_p(x,y)=x+y-xy$\\
                \hline
                Drastik&$T_D(x,y)=
                \begin{cases}
                y&\text{jika }x=1\\
                x&\text{jika }y=1\\
                0&\text{selainnya}
                \end{cases}$
                &
                $C_D(x,y)=
                \begin{cases}
                y&\text{jika }x=0\\
                x&\text{jika }y=0\\
                1&\text{selainnya}
                \end{cases}
                $
                \\
                \hline
                Nilpoten minimum/ maksimum&$T_{nM}(x,y)=
                \begin{cases}
                \min(x,y)&\text{jika }x+y> 1\\
                0&\text{selainnya}
                \end{cases}$&
                $
                C_{nM}(x,y)=
                \begin{cases}
                \max(x,y)&\text{jika }x+y<1\\
                1&\text{selainnya}
                \end{cases}
                $
                \\
                \hline
                Hasil kali Hamacher/ Jumlah Einstein&$T_{H_0}(x,y)=
                \begin{cases}
                0&\text{jika }x=y=0\\
                \dfrac{xy}{x+y-xy}&\text{selainnya}
                \end{cases}$&
                $
                C_{H_2}(x,y)=\dfrac{x+y}{1+xy}
                $
                \\
                \hline
            \end{tabular}
            \label{tabelnorma}
        }
    \end{table}
\end{document}

在此处输入图片描述 我想让表格中的所有内容垂直居中,并且让“Nama”(第一行和第一列)水平居中。如何实现?

答案1

我建议您使用tabular*环境并将相对字体大小切换为\footnotesize;这样您就可以摆脱\resizebox包装器。要使单元格内容垂直居中,我建议使用m而不是p列类型。最后但并非最不重要的是,我会通过删除所有垂直线和大多数水平线来使表格看起来更加开放。

在此处输入图片描述

\documentclass[a4paper,oneside,11pt]{book}
\usepackage[left=4cm,right=3cm,top=4cm,bottom=3cm]{geometry}
 
% new stuff:
\usepackage[indonesian]{babel} % is this correct?
\usepackage[skip=0.333\baselineskip]{caption}
\usepackage{amsmath}  % for 'cases' environment
\usepackage{booktabs} % for well-spaced horizontal rules
\usepackage{array}    % for '\newcolumntype' macro
\newcolumntype{C}{>{$}c<{$}} % centered, automatic math mode
\newcolumntype{P}[1]{>{\raggedright\arraybackslash}m{#1}}
\newlength\mylen

\begin{document}
\begin{table}[h!]
\captionsetup{font=small} % or: \captionsetup{font=footnotesize}
\footnotesize
\setlength\tabcolsep{0pt} % make LaTeX figure out intercol. whitespace amount
\settowidth{\mylen}{Hamacher/} % width of 1st col.
    \caption{Tabel dari $t$-norm dan $t$-conorm}
    \label{tabelnorma}
    \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} P{\mylen} CC @{}}
    \toprule
    Nama 
    & \text{$t$-norm} 
    & \text{$t$-conorm} \\
    \midrule
    Standar
    & T_m(x,y)=\min(x,y)
    & C_m(x,y)=\max(x,y)\\
    \addlinespace
    Jumlah terbatas
    & T_b(x,y)=\max(0,x+y-1)
    & C_b(x,y)=\min(1,x+y)\\
    \addlinespace
    Hasil kali\slash jumlah aljabar 
    & T_p(x,y)=xy
    & C_p(x,y)=x+y-xy\\
    \addlinespace
    Drastik
    & T_D(x,y)=
        \begin{cases}
           y & \text{jika $x=1$}\\
           x & \text{jika $y=1$}\\
           0 & \text{selainnya}
        \end{cases}
    & C_{\!D}(x,y)=
        \begin{cases}
           y & \text{jika $x=0$}\\
           x & \text{jika $y=0$}\\
           1 & \text{selainnya}
        \end{cases} \\
    \addlinespace
    Nilpoten minimum\slash maksimum
    & T_{nM}(x,y)=
        \begin{cases}
           \min(x,y) & \text{jika $x+y> 1$}\\
           0 & \text{selainnya}
        \end{cases}
    & C_{nM}(x,y)=
        \begin{cases}
           \max(x,y) & \text{jika $x+y<1$}\\
           1 & \text{selainnya}
        \end{cases} \\
    \addlinespace
    Hasil kali Hamacher\slash Jumlah Einstein
    & T_{H_0}(x,y)=
        \begin{cases}
           0 & \text{jika $x=y=0$}\\
           \dfrac{xy}{x+y-xy} & \text{selainnya}
        \end{cases}
    & C_{H_2}(x,y)=\dfrac{x+y}{1+xy} \\ \addlinespace
    \bottomrule
    \end{tabular*}
\end{table}
\end{document}

答案2

这是一个快速解决方案,用\hfill,第二个单词后面跟着\strut(零宽度字符)。

\hline
\hfill Nama\hfill \strut&t-norm&t-conorm\\
\hline

截屏

\documentclass[a4paper,oneside,11pt]{book}
\usepackage[left=4cm,right=3cm,top=4cm,bottom=3cm]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\begin{document}
    \begin{table}[h!]
        \centering
        \caption{Tabel dari t-norm dan t-conorm}
        \resizebox{\textwidth}{!}{
            \renewcommand{\arraystretch}{1.5}
            \begin{tabular}{|p{2cm}|c|c|}
                \hline
                \hfill Nama\hfill \strut&t-norm&t-conorm\\
                \hline
                Standar&$T_m(x,y)=\min(x,y)$&$C_m(x,y)=\max(x,y)$\\
                \hline
                Jumlah terbatas&$T_b(x,y)=\max(0,x+y-1)$&$C_b(x,y)=\min(1,x+y)$\\
                \hline
                Hasil kali/ jumlah aljabar&$T_p(x,y)=xy$&$C_p(x,y)=x+y-xy$\\
                \hline
                Drastik&$T_D(x,y)=
                \begin{cases}
                y&\text{jika }x=1\\
                x&\text{jika }y=1\\
                0&\text{selainnya}
                \end{cases}$
                &
                $C_D(x,y)=
                \begin{cases}
                y&\text{jika }x=0\\
                x&\text{jika }y=0\\
                1&\text{selainnya}
                \end{cases}
                $
                \\
                \hline
                Nilpoten minimum/ maksimum&$T_{nM}(x,y)=
                \begin{cases}
                \min(x,y)&\text{jika }x+y> 1\\
                0&\text{selainnya}
                \end{cases}$&
                $
                C_{nM}(x,y)=
                \begin{cases}
                \max(x,y)&\text{jika }x+y<1\\
                1&\text{selainnya}
                \end{cases}
                $
                \\
                \hline
                Hasil kali Hamacher/ Jumlah Einstein&$T_{H_0}(x,y)=
                \begin{cases}
                0&\text{jika }x=y=0\\
                \dfrac{xy}{x+y-xy}&\text{selainnya}
                \end{cases}$&
                $
                C_{H_2}(x,y)=\dfrac{x+y}{1+xy}
                $
                \\
                \hline
            \end{tabular}
            \label{tabelnorma}
        }
    \end{table}
\end{document}

相关内容