Problems with position of tikzpictures in beamer












4















Consider the following MWE:



documentclass{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage[ngerman]{babel}
usepackage{tikz,alphalph,amsmath}
setbeamertemplate{navigation symbols}{}
usetheme{AnnArbor}
usecolortheme{dolphin}
setbeamercolor{frametitle}{fg=structure,bg=white}
setbeamerfont{frametitle}{shape=rmbfseries}
newcommand{caesar}[1]{
centering
begin{tikzpicture}[every node/.style={draw,minimum width=1cm,minimum height=1cm}]
foreach k in {1,...,26}
{
pgfmathsetmacrosecure{int(k+#1)}
ifnumk=26
pgfmathsetmacromainx{mod(k,26)}
else
pgfmathsetmacromainx{mod(k,26)-1}
fi
pgfmathsetmacroxpos{mod(mainx,5)}
pgfmathsetmacrotestnumber{mod(k,5)}

ifcasetestnumber=0
pgfmathsetmacroypos{-floor(k/5)+1}
else
pgfmathsetmacroypos{-floor(k/5)}
fi


pgfmathsetmacroletter{int(mod(secure,26))}
ifnumletter=0
pgfmathsetmacroletter{26}
elsefi

node at (xpos,ypos) {strutalphalph{letter}};
}

node[draw=none] at (7,0) {$(x+textcolor{red}{e})mod 26$ mit $textcolor{red}{e} = #1$};
end{tikzpicture}
}
begin{document}
title{bf Title}
author{Name}
institute{Institute}
maketitle

begin{frame}{Cäsar-Verschlüsselung}
only<1>{
caesar{0}
}
only<2>{
caesar{1}
}
end{frame}
end{document}


Screenshot



As you see, the position of the tikzpicture in the third frame is different from the second one (it's a little bit shifted to the right). I guess it's related a kind of the boxes, which the package alphalph uses for the letters of sth. like that.



My questions is: How can I fix this "bug" (in meaning of that there is no shifting when the third frame appears)?










share|improve this question


















  • 1





    Set both tikzpictures to use the same size for their bounding box (use as bounding box option).

    – Skillmon
    Feb 23 at 11:35
















4















Consider the following MWE:



documentclass{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage[ngerman]{babel}
usepackage{tikz,alphalph,amsmath}
setbeamertemplate{navigation symbols}{}
usetheme{AnnArbor}
usecolortheme{dolphin}
setbeamercolor{frametitle}{fg=structure,bg=white}
setbeamerfont{frametitle}{shape=rmbfseries}
newcommand{caesar}[1]{
centering
begin{tikzpicture}[every node/.style={draw,minimum width=1cm,minimum height=1cm}]
foreach k in {1,...,26}
{
pgfmathsetmacrosecure{int(k+#1)}
ifnumk=26
pgfmathsetmacromainx{mod(k,26)}
else
pgfmathsetmacromainx{mod(k,26)-1}
fi
pgfmathsetmacroxpos{mod(mainx,5)}
pgfmathsetmacrotestnumber{mod(k,5)}

ifcasetestnumber=0
pgfmathsetmacroypos{-floor(k/5)+1}
else
pgfmathsetmacroypos{-floor(k/5)}
fi


pgfmathsetmacroletter{int(mod(secure,26))}
ifnumletter=0
pgfmathsetmacroletter{26}
elsefi

node at (xpos,ypos) {strutalphalph{letter}};
}

node[draw=none] at (7,0) {$(x+textcolor{red}{e})mod 26$ mit $textcolor{red}{e} = #1$};
end{tikzpicture}
}
begin{document}
title{bf Title}
author{Name}
institute{Institute}
maketitle

begin{frame}{Cäsar-Verschlüsselung}
only<1>{
caesar{0}
}
only<2>{
caesar{1}
}
end{frame}
end{document}


Screenshot



As you see, the position of the tikzpicture in the third frame is different from the second one (it's a little bit shifted to the right). I guess it's related a kind of the boxes, which the package alphalph uses for the letters of sth. like that.



My questions is: How can I fix this "bug" (in meaning of that there is no shifting when the third frame appears)?










share|improve this question


















  • 1





    Set both tikzpictures to use the same size for their bounding box (use as bounding box option).

    – Skillmon
    Feb 23 at 11:35














4












4








4








Consider the following MWE:



documentclass{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage[ngerman]{babel}
usepackage{tikz,alphalph,amsmath}
setbeamertemplate{navigation symbols}{}
usetheme{AnnArbor}
usecolortheme{dolphin}
setbeamercolor{frametitle}{fg=structure,bg=white}
setbeamerfont{frametitle}{shape=rmbfseries}
newcommand{caesar}[1]{
centering
begin{tikzpicture}[every node/.style={draw,minimum width=1cm,minimum height=1cm}]
foreach k in {1,...,26}
{
pgfmathsetmacrosecure{int(k+#1)}
ifnumk=26
pgfmathsetmacromainx{mod(k,26)}
else
pgfmathsetmacromainx{mod(k,26)-1}
fi
pgfmathsetmacroxpos{mod(mainx,5)}
pgfmathsetmacrotestnumber{mod(k,5)}

ifcasetestnumber=0
pgfmathsetmacroypos{-floor(k/5)+1}
else
pgfmathsetmacroypos{-floor(k/5)}
fi


pgfmathsetmacroletter{int(mod(secure,26))}
ifnumletter=0
pgfmathsetmacroletter{26}
elsefi

node at (xpos,ypos) {strutalphalph{letter}};
}

node[draw=none] at (7,0) {$(x+textcolor{red}{e})mod 26$ mit $textcolor{red}{e} = #1$};
end{tikzpicture}
}
begin{document}
title{bf Title}
author{Name}
institute{Institute}
maketitle

begin{frame}{Cäsar-Verschlüsselung}
only<1>{
caesar{0}
}
only<2>{
caesar{1}
}
end{frame}
end{document}


Screenshot



As you see, the position of the tikzpicture in the third frame is different from the second one (it's a little bit shifted to the right). I guess it's related a kind of the boxes, which the package alphalph uses for the letters of sth. like that.



My questions is: How can I fix this "bug" (in meaning of that there is no shifting when the third frame appears)?










share|improve this question














Consider the following MWE:



documentclass{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage[ngerman]{babel}
usepackage{tikz,alphalph,amsmath}
setbeamertemplate{navigation symbols}{}
usetheme{AnnArbor}
usecolortheme{dolphin}
setbeamercolor{frametitle}{fg=structure,bg=white}
setbeamerfont{frametitle}{shape=rmbfseries}
newcommand{caesar}[1]{
centering
begin{tikzpicture}[every node/.style={draw,minimum width=1cm,minimum height=1cm}]
foreach k in {1,...,26}
{
pgfmathsetmacrosecure{int(k+#1)}
ifnumk=26
pgfmathsetmacromainx{mod(k,26)}
else
pgfmathsetmacromainx{mod(k,26)-1}
fi
pgfmathsetmacroxpos{mod(mainx,5)}
pgfmathsetmacrotestnumber{mod(k,5)}

ifcasetestnumber=0
pgfmathsetmacroypos{-floor(k/5)+1}
else
pgfmathsetmacroypos{-floor(k/5)}
fi


pgfmathsetmacroletter{int(mod(secure,26))}
ifnumletter=0
pgfmathsetmacroletter{26}
elsefi

node at (xpos,ypos) {strutalphalph{letter}};
}

node[draw=none] at (7,0) {$(x+textcolor{red}{e})mod 26$ mit $textcolor{red}{e} = #1$};
end{tikzpicture}
}
begin{document}
title{bf Title}
author{Name}
institute{Institute}
maketitle

begin{frame}{Cäsar-Verschlüsselung}
only<1>{
caesar{0}
}
only<2>{
caesar{1}
}
end{frame}
end{document}


Screenshot



As you see, the position of the tikzpicture in the third frame is different from the second one (it's a little bit shifted to the right). I guess it's related a kind of the boxes, which the package alphalph uses for the letters of sth. like that.



My questions is: How can I fix this "bug" (in meaning of that there is no shifting when the third frame appears)?







tikz-pgf beamer positioning






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 23 at 11:24









current_usercurrent_user

3,4791737




3,4791737








  • 1





    Set both tikzpictures to use the same size for their bounding box (use as bounding box option).

    – Skillmon
    Feb 23 at 11:35














  • 1





    Set both tikzpictures to use the same size for their bounding box (use as bounding box option).

    – Skillmon
    Feb 23 at 11:35








1




1





Set both tikzpictures to use the same size for their bounding box (use as bounding box option).

– Skillmon
Feb 23 at 11:35





Set both tikzpictures to use the same size for their bounding box (use as bounding box option).

– Skillmon
Feb 23 at 11:35










1 Answer
1






active

oldest

votes


















7














The actual reason is way simpler. You included spurious spaces with the way you used only which lead to the shift. You have to make sure to comment out line endings using %:



documentclass{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage[ngerman]{babel}
usepackage{tikz,alphalph,amsmath}
setbeamertemplate{navigation symbols}{}
usetheme{AnnArbor}
usecolortheme{dolphin}
setbeamercolor{frametitle}{fg=structure,bg=white}
setbeamerfont{frametitle}{shape=rmbfseries}
newcommand{caesar}[1]{
centering
begin{tikzpicture}[every node/.style={draw,minimum width=1cm,minimum height=1cm}]
foreach k in {1,...,26}
{
pgfmathsetmacrosecure{int(k+#1)}
ifnumk=26
pgfmathsetmacromainx{mod(k,26)}
else
pgfmathsetmacromainx{mod(k,26)-1}
fi
pgfmathsetmacroxpos{mod(mainx,5)}
pgfmathsetmacrotestnumber{mod(k,5)}

ifcasetestnumber=0
pgfmathsetmacroypos{-floor(k/5)+1}
else
pgfmathsetmacroypos{-floor(k/5)}
fi


pgfmathsetmacroletter{int(mod(secure,26))}
ifnumletter=0
pgfmathsetmacroletter{26}
elsefi

node at (xpos,ypos) {strutmakebox[1em]{alphalph{letter}}};
}

node[draw=none] at (7,0) {$(x+textcolor{red}{e})mod 26$ mit $textcolor{red}{e} = #1$};
end{tikzpicture}
}
begin{document}
title{bf Title}
author{Name}
institute{Institute}
maketitle

begin{frame}{Cäsar-Verschlüsselung}
only<1>{%
caesar{0}%
}%
only<2>{%
caesar{1}%
}%
end{frame}
end{document}


enter image description here






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476308%2fproblems-with-position-of-tikzpictures-in-beamer%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    7














    The actual reason is way simpler. You included spurious spaces with the way you used only which lead to the shift. You have to make sure to comment out line endings using %:



    documentclass{beamer}
    usepackage[utf8]{inputenc}
    usepackage[T1]{fontenc}
    usepackage[ngerman]{babel}
    usepackage{tikz,alphalph,amsmath}
    setbeamertemplate{navigation symbols}{}
    usetheme{AnnArbor}
    usecolortheme{dolphin}
    setbeamercolor{frametitle}{fg=structure,bg=white}
    setbeamerfont{frametitle}{shape=rmbfseries}
    newcommand{caesar}[1]{
    centering
    begin{tikzpicture}[every node/.style={draw,minimum width=1cm,minimum height=1cm}]
    foreach k in {1,...,26}
    {
    pgfmathsetmacrosecure{int(k+#1)}
    ifnumk=26
    pgfmathsetmacromainx{mod(k,26)}
    else
    pgfmathsetmacromainx{mod(k,26)-1}
    fi
    pgfmathsetmacroxpos{mod(mainx,5)}
    pgfmathsetmacrotestnumber{mod(k,5)}

    ifcasetestnumber=0
    pgfmathsetmacroypos{-floor(k/5)+1}
    else
    pgfmathsetmacroypos{-floor(k/5)}
    fi


    pgfmathsetmacroletter{int(mod(secure,26))}
    ifnumletter=0
    pgfmathsetmacroletter{26}
    elsefi

    node at (xpos,ypos) {strutmakebox[1em]{alphalph{letter}}};
    }

    node[draw=none] at (7,0) {$(x+textcolor{red}{e})mod 26$ mit $textcolor{red}{e} = #1$};
    end{tikzpicture}
    }
    begin{document}
    title{bf Title}
    author{Name}
    institute{Institute}
    maketitle

    begin{frame}{Cäsar-Verschlüsselung}
    only<1>{%
    caesar{0}%
    }%
    only<2>{%
    caesar{1}%
    }%
    end{frame}
    end{document}


    enter image description here






    share|improve this answer




























      7














      The actual reason is way simpler. You included spurious spaces with the way you used only which lead to the shift. You have to make sure to comment out line endings using %:



      documentclass{beamer}
      usepackage[utf8]{inputenc}
      usepackage[T1]{fontenc}
      usepackage[ngerman]{babel}
      usepackage{tikz,alphalph,amsmath}
      setbeamertemplate{navigation symbols}{}
      usetheme{AnnArbor}
      usecolortheme{dolphin}
      setbeamercolor{frametitle}{fg=structure,bg=white}
      setbeamerfont{frametitle}{shape=rmbfseries}
      newcommand{caesar}[1]{
      centering
      begin{tikzpicture}[every node/.style={draw,minimum width=1cm,minimum height=1cm}]
      foreach k in {1,...,26}
      {
      pgfmathsetmacrosecure{int(k+#1)}
      ifnumk=26
      pgfmathsetmacromainx{mod(k,26)}
      else
      pgfmathsetmacromainx{mod(k,26)-1}
      fi
      pgfmathsetmacroxpos{mod(mainx,5)}
      pgfmathsetmacrotestnumber{mod(k,5)}

      ifcasetestnumber=0
      pgfmathsetmacroypos{-floor(k/5)+1}
      else
      pgfmathsetmacroypos{-floor(k/5)}
      fi


      pgfmathsetmacroletter{int(mod(secure,26))}
      ifnumletter=0
      pgfmathsetmacroletter{26}
      elsefi

      node at (xpos,ypos) {strutmakebox[1em]{alphalph{letter}}};
      }

      node[draw=none] at (7,0) {$(x+textcolor{red}{e})mod 26$ mit $textcolor{red}{e} = #1$};
      end{tikzpicture}
      }
      begin{document}
      title{bf Title}
      author{Name}
      institute{Institute}
      maketitle

      begin{frame}{Cäsar-Verschlüsselung}
      only<1>{%
      caesar{0}%
      }%
      only<2>{%
      caesar{1}%
      }%
      end{frame}
      end{document}


      enter image description here






      share|improve this answer


























        7












        7








        7







        The actual reason is way simpler. You included spurious spaces with the way you used only which lead to the shift. You have to make sure to comment out line endings using %:



        documentclass{beamer}
        usepackage[utf8]{inputenc}
        usepackage[T1]{fontenc}
        usepackage[ngerman]{babel}
        usepackage{tikz,alphalph,amsmath}
        setbeamertemplate{navigation symbols}{}
        usetheme{AnnArbor}
        usecolortheme{dolphin}
        setbeamercolor{frametitle}{fg=structure,bg=white}
        setbeamerfont{frametitle}{shape=rmbfseries}
        newcommand{caesar}[1]{
        centering
        begin{tikzpicture}[every node/.style={draw,minimum width=1cm,minimum height=1cm}]
        foreach k in {1,...,26}
        {
        pgfmathsetmacrosecure{int(k+#1)}
        ifnumk=26
        pgfmathsetmacromainx{mod(k,26)}
        else
        pgfmathsetmacromainx{mod(k,26)-1}
        fi
        pgfmathsetmacroxpos{mod(mainx,5)}
        pgfmathsetmacrotestnumber{mod(k,5)}

        ifcasetestnumber=0
        pgfmathsetmacroypos{-floor(k/5)+1}
        else
        pgfmathsetmacroypos{-floor(k/5)}
        fi


        pgfmathsetmacroletter{int(mod(secure,26))}
        ifnumletter=0
        pgfmathsetmacroletter{26}
        elsefi

        node at (xpos,ypos) {strutmakebox[1em]{alphalph{letter}}};
        }

        node[draw=none] at (7,0) {$(x+textcolor{red}{e})mod 26$ mit $textcolor{red}{e} = #1$};
        end{tikzpicture}
        }
        begin{document}
        title{bf Title}
        author{Name}
        institute{Institute}
        maketitle

        begin{frame}{Cäsar-Verschlüsselung}
        only<1>{%
        caesar{0}%
        }%
        only<2>{%
        caesar{1}%
        }%
        end{frame}
        end{document}


        enter image description here






        share|improve this answer













        The actual reason is way simpler. You included spurious spaces with the way you used only which lead to the shift. You have to make sure to comment out line endings using %:



        documentclass{beamer}
        usepackage[utf8]{inputenc}
        usepackage[T1]{fontenc}
        usepackage[ngerman]{babel}
        usepackage{tikz,alphalph,amsmath}
        setbeamertemplate{navigation symbols}{}
        usetheme{AnnArbor}
        usecolortheme{dolphin}
        setbeamercolor{frametitle}{fg=structure,bg=white}
        setbeamerfont{frametitle}{shape=rmbfseries}
        newcommand{caesar}[1]{
        centering
        begin{tikzpicture}[every node/.style={draw,minimum width=1cm,minimum height=1cm}]
        foreach k in {1,...,26}
        {
        pgfmathsetmacrosecure{int(k+#1)}
        ifnumk=26
        pgfmathsetmacromainx{mod(k,26)}
        else
        pgfmathsetmacromainx{mod(k,26)-1}
        fi
        pgfmathsetmacroxpos{mod(mainx,5)}
        pgfmathsetmacrotestnumber{mod(k,5)}

        ifcasetestnumber=0
        pgfmathsetmacroypos{-floor(k/5)+1}
        else
        pgfmathsetmacroypos{-floor(k/5)}
        fi


        pgfmathsetmacroletter{int(mod(secure,26))}
        ifnumletter=0
        pgfmathsetmacroletter{26}
        elsefi

        node at (xpos,ypos) {strutmakebox[1em]{alphalph{letter}}};
        }

        node[draw=none] at (7,0) {$(x+textcolor{red}{e})mod 26$ mit $textcolor{red}{e} = #1$};
        end{tikzpicture}
        }
        begin{document}
        title{bf Title}
        author{Name}
        institute{Institute}
        maketitle

        begin{frame}{Cäsar-Verschlüsselung}
        only<1>{%
        caesar{0}%
        }%
        only<2>{%
        caesar{1}%
        }%
        end{frame}
        end{document}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 23 at 11:42









        SkillmonSkillmon

        23.8k12248




        23.8k12248






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476308%2fproblems-with-position-of-tikzpictures-in-beamer%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How do I know what Microsoft account the skydrive app is syncing to?

            When does type information flow backwards in C++?

            Grease: Live!