나는 중앙 정렬(가로 및 세로)을 사용하여 테이블을 만들 것입니다. 나는 그것을 '규칙'으로 깨달았다. 불행히도 첫 번째 열은 이에 대해 반응하지 않습니다.
내 코드:
\documentclass[hyperref={pdfpagelabels=false}]{beamer}
% Die Hyperref Option hyperref={pdfpagelabels=false} verhindert die Warnung: Package hyperref Warning: Option `pdfpagelabels' is turned off (hyperref) because \thepage is undefined. Hyperref stopped early
\usetheme{CambridgeUS}
\usepackage{lmodern}
% lmodern (= Latin Modern) Paket verändert die verwendete Schriftart. Der Hauptunterschied ist die Darstellung der Schrift innerhalb von pdf Dateien. Latin Modern ist um einiges flüßiger.
\usepackage{beamerthemeshadow}
\usepackage[ngerman]{babel}
\usepackage{array}
\usepackage{eurosym}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pgf,tikz}
\usepackage{booktabs}
\usepackage{slashbox,pict2e}
\usetikzlibrary{arrows,positioning,fit}
\usetikzlibrary{shadows}
\definecolor{UniHHred}{RGB}{226,0,26}
\usefonttheme{professionalfonts} % default family is serif
\setbeamercolor{frametitle}{fg=black,bg=UniHHred}
\setbeamerfont{frametitle}{size=\large}
\setbeamertemplate{frametitle}{\color{black}\bfseries\insertframetitle\par\vskip-6pt\hrulefill}
\setbeamercolor{block title}{series=\bfseries,size=\huge,fg=black,bg=UniHHred}
\setbeamercolor{block body}{bg=gray!20!bg}
\setbeamercolor{itemize item}{fg=black}
\setbeamercolor{itemize subitem}{fg=black}
\setbeamercolor{title}{fg=black,bg=UniHHred}
\setbeamercolor{section in head/foot}{fg=black, bg=UniHHred}
\makeatother
\setbeamertemplate{footline}
{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=.25\paperwidth,ht=2.25ex,dp=1ex,center]{section in head/foot}%
\usebeamerfont{author in head/foot}\insertshortauthor
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,center]{section in head/foot}%
\usebeamerfont{title in head/foot}\insertshorttitle
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.25\paperwidth,ht=2.25ex,dp=1ex,center]{section in head/foot}%
\insertdate \qquad \insertframenumber{} / \inserttotalframenumber\hspace*{1ex}
\end{beamercolorbox}}%
\vskip0pt%
}
\makeatletter
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{headline}{}
\addtobeamertemplate{block begin}{%
\setlength{\textwidth}{0.9\textwidth}%
}{}
\usetikzlibrary{arrows,positioning}
\usetikzlibrary{calc}
\usetikzlibrary{shapes,snakes}
\newcommand*\xbar[1]{%
\hbox{%
\vbox{%
\hrule height 0.5pt % The actual bar
\kern0.5ex% % Distance between bar and symbol
\hbox{%
\kern-0.1em% % Shortening on the left side
\ensuremath{#1}%
\kern-0.1em% % Shortening on the right side
}%
}%
}%
}
\makeatletter
\g@addto@macro\normalsize{% <----
\setlength\abovedisplayskip{0pt}% <----
\setlength\belowdisplayskip{10pt}% <----
\setlength\abovedisplayshortskip{0pt}% <----
\setlength\belowdisplayshortskip{20pt}% <----
}
\makeatother
\tikzset{
declare function={
normcdf(\x,\m,\s)=1/(1 + exp(-0.07056*((\x-\m)/\s)^3 - 1.5976*(\x-\m)/\s));
}
}
\usepackage{tabularx}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}} % linksbündig mit Breitenangabe
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}} % zentriert mit Breitenangabe
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}} % rechtsbündig mit Breitenangabe
\usepackage[framemethod=TikZ]{mdframed}
\newcounter{form}[section]\setcounter{form}{0}
\renewcommand{\theform}{\arabic{section}.\arabic{form}}
\newenvironment{form}[2][]{%
\refstepcounter{form}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!40]
{\strut Formel/Erläuterung};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!40]
{\strut Formel/Erläuterung:~#1};}}%
}%
\mdfsetup{innertopmargin=5pt,innerbottommargin=15pt,linecolor=blue!40,%
linewidth=2pt,topline=true,%
frametitleaboveskip=\dimexpr-\ht\strutbox\relax
}
\begin{mdframed}[]\relax%
\label{#2}}{\end{mdframed}}
\begin{document}
\begin{center}\begin{tabular}{|*{5}{C{1cm}|}}\hline
\rule{0pt}{12pt} $z_i$ & $-\frac{130}{81}$ & $-\frac{10}{27}$ & $\frac{70}{81}$ & $\frac{170}{81}$ \\\hline
\rule{0pt}{12pt} $f(z_i)$ & $0,2$ & $0,4$ & $0,3$ & $0,1$ \\\hline
\end{tabular}
\end{center}
\end{document}
내 문제의 사진은 다음과 같습니다.
답변1
makecell
다음 을 사용할 수 있습니다 collcell
.
\documentclass{article}
\usepackage{array,makecell,collcell}
\newcolumntype{C}{>{\collectcell\CELL}c<{\endcollectcell}}
\begin{document}
\begin{center}
\makegapedcells\setcellgapes{5pt}
\newcommand\CELL[1]{\makebox[1cm]{#1}}
\begin{tabular}{|*{5}{C|}}
\hline
$z_i$ & $-\frac{130}{81}$ & $-\frac{10}{27}$ &
$\frac{70}{81}$ & $\frac{170}{81}$ \\\hline
$f(z_i)$ & $0{,}2$ & $0{,}4$ & $0{,}3$ & $0{,}1$ \\\hline
\end{tabular}
\end{center}
\end{document}
명령 은 \CELL
테이블을 사용하기 전에 정의를 가져와야 합니다. 모든 셀이 길이를 공유하는 경우 서문에 정의를 넣을 수 있습니다. \renewcommand
물론 로컬로 사용할 수도 있습니다 .
답변2
나는 s를 사용하는 것이 깨끗한 해결책이라고 생각하지 않습니다 rule
. 예를 들어 \renewcommand{\arraystretch}{1.2}
. 대부분의 코드가 문제와 관련이 없는 것 같아서 코드의 관련 부분만 포함했습니다.
\documentclass[hyperref={pdfpagelabels=false}]{beamer}
\usefonttheme{professionalfonts} % default family is serif
\usepackage{array,lmodern}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}
\begin{frame}
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{|*{5}{C{1cm}|}}\hline
$z_i^{}$ & $-\frac{130}{81}$ & $-\frac{10}{27}$ & $\frac{70}{81}$ & $\frac{170}{81}$ \\ \hline
$f(z_i)$ & $0,2$ & $0,4$ & $0,3$ & $0,1$ \\ \hline
\end{tabular}
\end{frame}
\end{document}