1

I would create a table with cnter alignment (horizontal and vertikal). I realized it with "rule". Unfortunately the first colum does not react on this.

My code:

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

Here is a picture of my problem:

enter image description here

  • (1) Can you minimize the code? Most of it doesn't seem to be related with the problem. (2) I get compile errors, since series and size are not valid keys for \setbeamercolor. (3) Have you looked at the optional (first) argument of \rule that shifts the rule w.r.t. to the baseline? – gernot Apr 26 '17 at 12:16
2

You can use makecell and 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}

The \CELL command should get a definition before using the table. You can put the definition in the preamble, if all of your cells share the length; you can locally use \renewcommand, of course.

enter image description here

0

I don't think using rules is a clean solution, you can increase the height of rows by issuing, e.g., \renewcommand{\arraystretch}{1.2}. I included only the relevant parts of the code because most of your code doesn't seem to be related to the problem.

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

enter image description here

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.