3

I use \usetheme{Warsaw} '\rightskip\rightmargin' to help me use beamer in Arabic, but it doesn't let me centre tikzpicture well even though I use: \centering, begin{figure}[!h]...

\documentclass{beamer}

\usepackage[utf8]{inputenc}
\usepackage[swedish]{babel}
\usepackage{float}
\usepackage{subfig}
\usepackage{tikz,tkz-tab}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{graphicx}
\usetikzlibrary{calc}
\usepackage{float}
\usepackage{amssymb}
\usetheme{Warsaw}
\rightskip\rightmargin
%+++++++++++++++++ def block itemize
\makeatletter
\newenvironment{bitemize}{%
  \ifnum\@itemdepth >2\relax\@toodeep\else%
      \advance\@itemdepth\@ne%
      \beamer@computepref\@itemdepth%
      \usebeamerfont{itemize/enumerate \beameritemnestingprefix body}%
      \usebeamercolor[fg]{itemize/enumerate \beameritemnestingprefix body}%
      \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body begin}%
      \begin{list}
        {%
            \usebeamertemplate{itemize \beameritemnestingprefix item}%
        }%
        { \itemindent=1.75em%
            \def\makelabel##1{%
              {%  
                  \hss\llap{{%
                    \usebeamerfont*{itemize \beameritemnestingprefix item}%
                        \usebeamercolor[fg]{itemize \beameritemnestingprefix item}##1}}%
              }%  
            }%  
        }
        \raggedright
  \fi
}
{
  \end{list}
  \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body end}%
}
\expandafter\let\csname beamer@@tmpop@itemize item@default\endcsname\relax
\expandafter\let\csname beamer@@tmpop@itemize subitem@default\endcsname\relax
\expandafter\let\csname beamer@@tmpop@itemize subsubitem@default\endcsname\relax
\makeatother
%+++++++++++++++++
\rightskip\rightmargin
\title{}

\author{}

\date{}

\begin{document}

\begin{frame}{First section 3\dots}
\begin{figure}[!h]
\centering
\begin{tikzpicture}
   \tkzTabInit{$x$ / 1 , $x^{2}-1$ / 1}{$-\infty$, $-1$, $1$, $+\infty$}
   \tkzTabLine{ , +, z, -, z, +, }
\end{tikzpicture}
\end{figure}

\end{frame}

\end{document}

enter image description here

6
  • 1
    A bit hard to center something that is wider than the text width
    – daleif
    Apr 3, 2020 at 10:29
  • @daleif Please, How can I adjust to being smaller than the text width ?
    – Educ
    Apr 3, 2020 at 10:31
  • First of what exactly is it you are trying to show? This just looks like a table to me, so why use tikz for it?
    – daleif
    Apr 3, 2020 at 10:33
  • it's hard and ugly to create it without using tikz-table
    – Educ
    Apr 3, 2020 at 10:34
  • No this is ugly. No one uses vertical lines in tables anymore. As far as I can see this is just showing how the function behaves.
    – daleif
    Apr 3, 2020 at 10:36

2 Answers 2

3

You need to change default settings of the tkz-tab picture, i.e. make them narrower. For example with \tkzTabInit[lgt=1.2,espcl=2]{...}.

MWE:

\documentclass{beamer}
\usetheme{Warsaw}

\usepackage[swedish]{babel}
\usepackage{subfig}
\usepackage{tikz,tkz-tab}
\usetikzlibrary{calc}
\usepackage{mathtools, amssymb}

\begin{document}
\begin{frame}{First section 3\dots}
    \begin{figure}
    \small
\begin{tikzpicture}
\tkzTabInit[lgt=1.2,espcl=2]% new settings for tkz-tab
            {$x$ / 1 , $x^{2}-1$ / 1}{$-\infty$, $-1$, $1$, $+\infty$}
\tkzTabLine{ , +, z, -, z, +, }
\end{tikzpicture}
    \end{figure}
\end{frame}
\end{document}

enter image description here

Note:

  • beamer loadgraphicx` package, so it is not needed to load it again.
  • why you need float package? for positioning of float is not needed since figure in beamer doesn't float
  • mathtools load amsmath, so you not load it again
1
  • +1 upvote Thank you very much
    – Educ
    Apr 3, 2020 at 11:12
3

I see no reason at all to use tikz here

\documentclass{beamer}

\usepackage[utf8]{inputenc}
\usepackage[swedish,english]{babel}
\usepackage{float}
\usepackage{subfig}
\usepackage{tikz,tkz-tab}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{graphicx}
\usetikzlibrary{calc}
\usepackage{float}
\usepackage{amssymb}
\usepackage{booktabs}
\usetheme{Warsaw}
\rightskip\rightmargin
%+++++++++++++++++ def block itemize
%+++++++++++++++++
\rightskip\rightmargin
\begin{document}

\begin{frame}{First section 3\dots}
\begin{figure}
\centering
\setlength\tabcolsep{10pt}
\begin{tabular}{@{\hspace{6pt}}*{9}{c}@{\hspace{6pt}}}
\toprule
$x$     & $-\infty$ &     & $-1$ &     & $1$ &   & $\infty$ \\
\midrule
$x^2-1$ &           & $+$ & $0$  & $-$ & $0$ & + & \\
\bottomrule
\end{tabular}
\caption{Functional behavior for $x^2-1$}
\end{figure}

\end{frame}

\end{document}

enter image description here

1
  • +1 upvote Thank you
    – Educ
    Apr 3, 2020 at 11:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .