TransWikia.com

Make a table in beamer, error in first column

TeX - LaTeX Asked on January 21, 2021

I want to show a table in beamer.
With this code below, why it’s get error, first column size can’t be 2 cm, and first column no vertical line? How to fix it?

documentclass[xcolor=dvipsnames, 10pt,notheorems]{beamer}
usetheme{Antibes}
usecolortheme[named=Red]{structure}
usepackage{amssymb}
usepackage{amsfonts}
usepackage{amsmath}
usepackage{xcolor}
usepackage[bahasa]{babel}
setbeamertemplate{caption}[numbered]
begin{document}

begin{frame}{CONTOH T-NORM DAN T-CONORM}
    begin{table}[h!]
        centering
        caption{Tabel dari t-norm dan t-conorm}
        resizebox{textwidth}{!}{
            renewcommand{arraystretch}{1.5}
            begin{tabular}{|m{2cm}|c|c|}
                hline
                textbf{Nama}strut&textbf{t-norm}&textbf{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{frame}
end{document}

enter image description here
enter image description here

2 Answers

I would redesign your table as follows:

  • remove resize box
  • add array package (bot already mentioned in comments)
  • remove xcolor, it is already loaded by beamer
  • use scriptsize font size
  • usec changepage package that can increase table width
  • use cellspace for adding vertical spaces in the last two columns' cells
  • reduce width of the first column to 15mm

enter image description here

documentclass[xcolor=dvipsnames, 10pt,notheorems]{beamer}
usetheme{Antibes}
usecolortheme[named=Red]{structure}
setbeamertemplate{caption}[numbered]

%usepackage[bahasa]{babel}
usepackage{array, cellspace}
usepackage{amsmath, amssymb}
usepackage{changepage}
begin{document}

begin{frame}
frametitle{CONTOH T-NORM DAN T-CONORM}
    begin{table}
setlengthcellspacetoplimit{3pt}
setlengthcellspacebottomlimit{3pt}
    setlengthtabcolsep{4pt}
    scriptsize
    centering
begin{adjustwidth}{-2em}{-2em}
        caption{Tabel dari t-norm dan t-conorm}
        label{tabelnorma}
            begin{tabular}{|>{raggedright}m{13mm}|Sc|Sc|}
                hline
                textbf{Nama}strut&textbf{t-norm}&textbf{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}
end{adjustwidth}
    end{table}
end{frame}
end{document}

Correct answer by Zarko on January 21, 2021

Here's a solution that's quite similar to the one provided by @Zarko, but without any vertical lines and only one, but well-spaced horizontal line. Since tables (and figures) don't "float" in beamer documents, I've also omitted the begin{table}, caption, label, and end{table} instructions.

enter image description here

documentclass[xcolor=dvipsnames, 10pt,notheorems]{beamer}
usetheme{Antibes}
usecolortheme[named=Red]{structure}
usepackage{amssymb,amsmath}
usepackage{xcolor}
usepackage[bahasa]{babel}
setbeamertemplate{caption}[numbered]

%% new:
usepackage{booktabs,ragged2e}
usepackage{tabularx}
renewcommand{tabularxcolumn}[1]{m{#1}}
newcolumntype{L}{>{hspace{0pt}RaggedRight}X}
newcolumntype{C}{>{$}c<{$}} % centered, automatic math

begin{document}

begin{frame}{Contoh $t$-norm dan $t$-conorm}
scriptsize
setlengthtabcolsep{2pt}

begin{tabularx}{textwidth}{@{} LCC @{}}
    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 kalislash 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 minimumslash 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 Hamacherslash Jumlah Einstein
    &T_{H_0}(x,y)=
     begin{cases}
     0                & text{jika $x=y=0$}
     frac{xy}{x+y-xy}& text{selainnya}
     end{cases}
    & C_{H_2}(x,y)=dfrac{x+y}{1+xy}
end{tabularx}
end{frame}
end{document}

Answered by Mico on January 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP