Drawing stacks side-by-side in LaTeX












7















In this question, Alan Munn provided an example of how to draw a stack in LaTeX:



documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.multipart}
begin{document}
begin{tikzpicture}[stack/.style={rectangle split, rectangle split parts=#1,draw, anchor=center}]
node[stack=5] {
nodepart{two}a
nodepart{three}b
nodepart{four}c
nodepart{five}d
};
end{tikzpicture}

end{document}


output of code



However, I would like to display 4 stacks side-by-side. How can this be done?










share|improve this question























  • should be some distance between your "staks"? are all stack have the same number and size of cells? or this stacks form a matrix?

    – Zarko
    Dec 5 '18 at 19:57











  • It dosn't matter how much distance is between the stacks. The stacks will have different amounts of cells but should all be aligned the the bottom. Cells may have different sizes.

    – Paradox
    Dec 5 '18 at 20:12


















7















In this question, Alan Munn provided an example of how to draw a stack in LaTeX:



documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.multipart}
begin{document}
begin{tikzpicture}[stack/.style={rectangle split, rectangle split parts=#1,draw, anchor=center}]
node[stack=5] {
nodepart{two}a
nodepart{three}b
nodepart{four}c
nodepart{five}d
};
end{tikzpicture}

end{document}


output of code



However, I would like to display 4 stacks side-by-side. How can this be done?










share|improve this question























  • should be some distance between your "staks"? are all stack have the same number and size of cells? or this stacks form a matrix?

    – Zarko
    Dec 5 '18 at 19:57











  • It dosn't matter how much distance is between the stacks. The stacks will have different amounts of cells but should all be aligned the the bottom. Cells may have different sizes.

    – Paradox
    Dec 5 '18 at 20:12
















7












7








7


1






In this question, Alan Munn provided an example of how to draw a stack in LaTeX:



documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.multipart}
begin{document}
begin{tikzpicture}[stack/.style={rectangle split, rectangle split parts=#1,draw, anchor=center}]
node[stack=5] {
nodepart{two}a
nodepart{three}b
nodepart{four}c
nodepart{five}d
};
end{tikzpicture}

end{document}


output of code



However, I would like to display 4 stacks side-by-side. How can this be done?










share|improve this question














In this question, Alan Munn provided an example of how to draw a stack in LaTeX:



documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.multipart}
begin{document}
begin{tikzpicture}[stack/.style={rectangle split, rectangle split parts=#1,draw, anchor=center}]
node[stack=5] {
nodepart{two}a
nodepart{three}b
nodepart{four}c
nodepart{five}d
};
end{tikzpicture}

end{document}


output of code



However, I would like to display 4 stacks side-by-side. How can this be done?







tikz-pgf stack






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 5 '18 at 19:53









ParadoxParadox

1386




1386













  • should be some distance between your "staks"? are all stack have the same number and size of cells? or this stacks form a matrix?

    – Zarko
    Dec 5 '18 at 19:57











  • It dosn't matter how much distance is between the stacks. The stacks will have different amounts of cells but should all be aligned the the bottom. Cells may have different sizes.

    – Paradox
    Dec 5 '18 at 20:12





















  • should be some distance between your "staks"? are all stack have the same number and size of cells? or this stacks form a matrix?

    – Zarko
    Dec 5 '18 at 19:57











  • It dosn't matter how much distance is between the stacks. The stacks will have different amounts of cells but should all be aligned the the bottom. Cells may have different sizes.

    – Paradox
    Dec 5 '18 at 20:12



















should be some distance between your "staks"? are all stack have the same number and size of cells? or this stacks form a matrix?

– Zarko
Dec 5 '18 at 19:57





should be some distance between your "staks"? are all stack have the same number and size of cells? or this stacks form a matrix?

– Zarko
Dec 5 '18 at 19:57













It dosn't matter how much distance is between the stacks. The stacks will have different amounts of cells but should all be aligned the the bottom. Cells may have different sizes.

– Paradox
Dec 5 '18 at 20:12







It dosn't matter how much distance is between the stacks. The stacks will have different amounts of cells but should all be aligned the the bottom. Cells may have different sizes.

– Paradox
Dec 5 '18 at 20:12












4 Answers
4






active

oldest

votes


















7














To place additional stacks just portion the new nodes appropriately:



enter image description here



Code:



documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.multipart}

begin{document}
begin{tikzpicture}[
stack/.style={rectangle split, rectangle split parts=#1,draw, anchor=center}
]

node[stack=5] (A) {
nodepart{two}a
nodepart{three}b
nodepart{four}c
nodepart{five}d
};
node[stack=5, right of=A] (B) {
nodepart{two}a
nodepart{three}b
nodepart{four}c
nodepart{five}d
};
node[stack=5, right of=B] (C) {
nodepart{two}a
nodepart{three}b
nodepart{four}c
nodepart{five}d
};
node[stack=5, right of=C] (D) {
nodepart{two}a
nodepart{three}b
nodepart{four}c
nodepart{five}d
};

end{tikzpicture}%
end{document}





share|improve this answer































    2














    with library matrix:



    documentclass{article}
    usepackage{tikz}
    usetikzlibrary{matrix, positioning}


    begin{document}
    begin{tikzpicture}[node distance=1cm]
    matrix (m) [matrix of nodes,
    nodes={draw, minimum width=1.5em, minimum height=2ex, outer sep=0pt},
    row sep = -pgflinewidth,
    column sep = -pgflinewidth % <--- as matrix
    ]
    { a & a & a & a \
    b & b & b & b \
    c & c & c & c \
    d & d & d & d \
    };
    matrix (n) [right=of m,
    matrix of nodes,
    nodes={draw, minimum width=1.5em, minimum height=2ex, outer sep=0pt},
    row sep = -pgflinewidth,
    column sep = 2em % <--- as separate stacks
    ]
    { a & a & a & a \
    b & b & b & b \
    c & c & c & c \
    d & d & d & d \
    };
    end{tikzpicture}
    end{document}


    enter image description here






    share|improve this answer































      2














      Really just 4 fun (and to answer a TikZ question with a non-TikZ answer, usually I am doing the opposite ;-).



      documentclass{article}
      usepackage{youngtab}
      begin{document}
      young(~,a,b,c,~)quadyoung(~,a,b,c,~)quadyoung(~,a,b,c,~)quadyoung(~,a,b,c,~)
      end{document}


      enter image description here






      share|improve this answer































        2














        Here I use stackengine instead of tikz. I create the macro wstack with a comma separated list to stack. The term wboxstrut defines the minimum vertical footprint of the stacked items, initially set to the footprint of w and later changed to strut, which will have the effect of aligning all box edges.



        Automatically adjusts to content width.



        It uses fboxrule and fboxsep to define the box rule and offset.



        documentclass{article}
        usepackage{stackengine,listofitems}
        defwboxwidth{.7em}
        defwboxstrut{vphantom{w}}
        newcommandwbox[1]{fbox{makebox[wboxwidth]{#1wboxstrut}}}
        newcommandwstack[1]{%
        setsepchar{,}%
        setstackEOL{,}%
        savestacktmp{Shortstack{#1}}%
        defwboxwidth{wdtmpcontent}%
        readlistboxitems{#1}%
        savestackboxbuild{wbox{boxitems[-1]}}%
        foreachitemxinboxitems{%
        ifnumxcnt=1relaxelse%
        savestackboxbuild{stackon[-fboxrule]{boxbuild}{wbox{boxitems[-xcnt]}}}%
        fi%
        }%
        boxbuild%
        }
        begin{document}
        wstack{,a,b,c,d}
        wstack{,a,b,c}
        wstack{b,c,d}
        wstack{,aaa,b,c,d}qquad
        defwboxstrut{strut}
        wstack{,a,b,c,d}
        wstack{,a,b,c}
        wstack{b,c,d}
        wstack{,aaa,b,c,d}
        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%2f463378%2fdrawing-stacks-side-by-side-in-latex%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          4 Answers
          4






          active

          oldest

          votes








          4 Answers
          4






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          7














          To place additional stacks just portion the new nodes appropriately:



          enter image description here



          Code:



          documentclass{article}
          usepackage{tikz}
          usetikzlibrary{shapes.multipart}

          begin{document}
          begin{tikzpicture}[
          stack/.style={rectangle split, rectangle split parts=#1,draw, anchor=center}
          ]

          node[stack=5] (A) {
          nodepart{two}a
          nodepart{three}b
          nodepart{four}c
          nodepart{five}d
          };
          node[stack=5, right of=A] (B) {
          nodepart{two}a
          nodepart{three}b
          nodepart{four}c
          nodepart{five}d
          };
          node[stack=5, right of=B] (C) {
          nodepart{two}a
          nodepart{three}b
          nodepart{four}c
          nodepart{five}d
          };
          node[stack=5, right of=C] (D) {
          nodepart{two}a
          nodepart{three}b
          nodepart{four}c
          nodepart{five}d
          };

          end{tikzpicture}%
          end{document}





          share|improve this answer




























            7














            To place additional stacks just portion the new nodes appropriately:



            enter image description here



            Code:



            documentclass{article}
            usepackage{tikz}
            usetikzlibrary{shapes.multipart}

            begin{document}
            begin{tikzpicture}[
            stack/.style={rectangle split, rectangle split parts=#1,draw, anchor=center}
            ]

            node[stack=5] (A) {
            nodepart{two}a
            nodepart{three}b
            nodepart{four}c
            nodepart{five}d
            };
            node[stack=5, right of=A] (B) {
            nodepart{two}a
            nodepart{three}b
            nodepart{four}c
            nodepart{five}d
            };
            node[stack=5, right of=B] (C) {
            nodepart{two}a
            nodepart{three}b
            nodepart{four}c
            nodepart{five}d
            };
            node[stack=5, right of=C] (D) {
            nodepart{two}a
            nodepart{three}b
            nodepart{four}c
            nodepart{five}d
            };

            end{tikzpicture}%
            end{document}





            share|improve this answer


























              7












              7








              7







              To place additional stacks just portion the new nodes appropriately:



              enter image description here



              Code:



              documentclass{article}
              usepackage{tikz}
              usetikzlibrary{shapes.multipart}

              begin{document}
              begin{tikzpicture}[
              stack/.style={rectangle split, rectangle split parts=#1,draw, anchor=center}
              ]

              node[stack=5] (A) {
              nodepart{two}a
              nodepart{three}b
              nodepart{four}c
              nodepart{five}d
              };
              node[stack=5, right of=A] (B) {
              nodepart{two}a
              nodepart{three}b
              nodepart{four}c
              nodepart{five}d
              };
              node[stack=5, right of=B] (C) {
              nodepart{two}a
              nodepart{three}b
              nodepart{four}c
              nodepart{five}d
              };
              node[stack=5, right of=C] (D) {
              nodepart{two}a
              nodepart{three}b
              nodepart{four}c
              nodepart{five}d
              };

              end{tikzpicture}%
              end{document}





              share|improve this answer













              To place additional stacks just portion the new nodes appropriately:



              enter image description here



              Code:



              documentclass{article}
              usepackage{tikz}
              usetikzlibrary{shapes.multipart}

              begin{document}
              begin{tikzpicture}[
              stack/.style={rectangle split, rectangle split parts=#1,draw, anchor=center}
              ]

              node[stack=5] (A) {
              nodepart{two}a
              nodepart{three}b
              nodepart{four}c
              nodepart{five}d
              };
              node[stack=5, right of=A] (B) {
              nodepart{two}a
              nodepart{three}b
              nodepart{four}c
              nodepart{five}d
              };
              node[stack=5, right of=B] (C) {
              nodepart{two}a
              nodepart{three}b
              nodepart{four}c
              nodepart{five}d
              };
              node[stack=5, right of=C] (D) {
              nodepart{two}a
              nodepart{three}b
              nodepart{four}c
              nodepart{five}d
              };

              end{tikzpicture}%
              end{document}






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Dec 5 '18 at 19:56









              Peter GrillPeter Grill

              164k25437749




              164k25437749























                  2














                  with library matrix:



                  documentclass{article}
                  usepackage{tikz}
                  usetikzlibrary{matrix, positioning}


                  begin{document}
                  begin{tikzpicture}[node distance=1cm]
                  matrix (m) [matrix of nodes,
                  nodes={draw, minimum width=1.5em, minimum height=2ex, outer sep=0pt},
                  row sep = -pgflinewidth,
                  column sep = -pgflinewidth % <--- as matrix
                  ]
                  { a & a & a & a \
                  b & b & b & b \
                  c & c & c & c \
                  d & d & d & d \
                  };
                  matrix (n) [right=of m,
                  matrix of nodes,
                  nodes={draw, minimum width=1.5em, minimum height=2ex, outer sep=0pt},
                  row sep = -pgflinewidth,
                  column sep = 2em % <--- as separate stacks
                  ]
                  { a & a & a & a \
                  b & b & b & b \
                  c & c & c & c \
                  d & d & d & d \
                  };
                  end{tikzpicture}
                  end{document}


                  enter image description here






                  share|improve this answer




























                    2














                    with library matrix:



                    documentclass{article}
                    usepackage{tikz}
                    usetikzlibrary{matrix, positioning}


                    begin{document}
                    begin{tikzpicture}[node distance=1cm]
                    matrix (m) [matrix of nodes,
                    nodes={draw, minimum width=1.5em, minimum height=2ex, outer sep=0pt},
                    row sep = -pgflinewidth,
                    column sep = -pgflinewidth % <--- as matrix
                    ]
                    { a & a & a & a \
                    b & b & b & b \
                    c & c & c & c \
                    d & d & d & d \
                    };
                    matrix (n) [right=of m,
                    matrix of nodes,
                    nodes={draw, minimum width=1.5em, minimum height=2ex, outer sep=0pt},
                    row sep = -pgflinewidth,
                    column sep = 2em % <--- as separate stacks
                    ]
                    { a & a & a & a \
                    b & b & b & b \
                    c & c & c & c \
                    d & d & d & d \
                    };
                    end{tikzpicture}
                    end{document}


                    enter image description here






                    share|improve this answer


























                      2












                      2








                      2







                      with library matrix:



                      documentclass{article}
                      usepackage{tikz}
                      usetikzlibrary{matrix, positioning}


                      begin{document}
                      begin{tikzpicture}[node distance=1cm]
                      matrix (m) [matrix of nodes,
                      nodes={draw, minimum width=1.5em, minimum height=2ex, outer sep=0pt},
                      row sep = -pgflinewidth,
                      column sep = -pgflinewidth % <--- as matrix
                      ]
                      { a & a & a & a \
                      b & b & b & b \
                      c & c & c & c \
                      d & d & d & d \
                      };
                      matrix (n) [right=of m,
                      matrix of nodes,
                      nodes={draw, minimum width=1.5em, minimum height=2ex, outer sep=0pt},
                      row sep = -pgflinewidth,
                      column sep = 2em % <--- as separate stacks
                      ]
                      { a & a & a & a \
                      b & b & b & b \
                      c & c & c & c \
                      d & d & d & d \
                      };
                      end{tikzpicture}
                      end{document}


                      enter image description here






                      share|improve this answer













                      with library matrix:



                      documentclass{article}
                      usepackage{tikz}
                      usetikzlibrary{matrix, positioning}


                      begin{document}
                      begin{tikzpicture}[node distance=1cm]
                      matrix (m) [matrix of nodes,
                      nodes={draw, minimum width=1.5em, minimum height=2ex, outer sep=0pt},
                      row sep = -pgflinewidth,
                      column sep = -pgflinewidth % <--- as matrix
                      ]
                      { a & a & a & a \
                      b & b & b & b \
                      c & c & c & c \
                      d & d & d & d \
                      };
                      matrix (n) [right=of m,
                      matrix of nodes,
                      nodes={draw, minimum width=1.5em, minimum height=2ex, outer sep=0pt},
                      row sep = -pgflinewidth,
                      column sep = 2em % <--- as separate stacks
                      ]
                      { a & a & a & a \
                      b & b & b & b \
                      c & c & c & c \
                      d & d & d & d \
                      };
                      end{tikzpicture}
                      end{document}


                      enter image description here







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Dec 5 '18 at 20:11









                      ZarkoZarko

                      122k865160




                      122k865160























                          2














                          Really just 4 fun (and to answer a TikZ question with a non-TikZ answer, usually I am doing the opposite ;-).



                          documentclass{article}
                          usepackage{youngtab}
                          begin{document}
                          young(~,a,b,c,~)quadyoung(~,a,b,c,~)quadyoung(~,a,b,c,~)quadyoung(~,a,b,c,~)
                          end{document}


                          enter image description here






                          share|improve this answer




























                            2














                            Really just 4 fun (and to answer a TikZ question with a non-TikZ answer, usually I am doing the opposite ;-).



                            documentclass{article}
                            usepackage{youngtab}
                            begin{document}
                            young(~,a,b,c,~)quadyoung(~,a,b,c,~)quadyoung(~,a,b,c,~)quadyoung(~,a,b,c,~)
                            end{document}


                            enter image description here






                            share|improve this answer


























                              2












                              2








                              2







                              Really just 4 fun (and to answer a TikZ question with a non-TikZ answer, usually I am doing the opposite ;-).



                              documentclass{article}
                              usepackage{youngtab}
                              begin{document}
                              young(~,a,b,c,~)quadyoung(~,a,b,c,~)quadyoung(~,a,b,c,~)quadyoung(~,a,b,c,~)
                              end{document}


                              enter image description here






                              share|improve this answer













                              Really just 4 fun (and to answer a TikZ question with a non-TikZ answer, usually I am doing the opposite ;-).



                              documentclass{article}
                              usepackage{youngtab}
                              begin{document}
                              young(~,a,b,c,~)quadyoung(~,a,b,c,~)quadyoung(~,a,b,c,~)quadyoung(~,a,b,c,~)
                              end{document}


                              enter image description here







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Dec 5 '18 at 20:46









                              marmotmarmot

                              91.6k4106199




                              91.6k4106199























                                  2














                                  Here I use stackengine instead of tikz. I create the macro wstack with a comma separated list to stack. The term wboxstrut defines the minimum vertical footprint of the stacked items, initially set to the footprint of w and later changed to strut, which will have the effect of aligning all box edges.



                                  Automatically adjusts to content width.



                                  It uses fboxrule and fboxsep to define the box rule and offset.



                                  documentclass{article}
                                  usepackage{stackengine,listofitems}
                                  defwboxwidth{.7em}
                                  defwboxstrut{vphantom{w}}
                                  newcommandwbox[1]{fbox{makebox[wboxwidth]{#1wboxstrut}}}
                                  newcommandwstack[1]{%
                                  setsepchar{,}%
                                  setstackEOL{,}%
                                  savestacktmp{Shortstack{#1}}%
                                  defwboxwidth{wdtmpcontent}%
                                  readlistboxitems{#1}%
                                  savestackboxbuild{wbox{boxitems[-1]}}%
                                  foreachitemxinboxitems{%
                                  ifnumxcnt=1relaxelse%
                                  savestackboxbuild{stackon[-fboxrule]{boxbuild}{wbox{boxitems[-xcnt]}}}%
                                  fi%
                                  }%
                                  boxbuild%
                                  }
                                  begin{document}
                                  wstack{,a,b,c,d}
                                  wstack{,a,b,c}
                                  wstack{b,c,d}
                                  wstack{,aaa,b,c,d}qquad
                                  defwboxstrut{strut}
                                  wstack{,a,b,c,d}
                                  wstack{,a,b,c}
                                  wstack{b,c,d}
                                  wstack{,aaa,b,c,d}
                                  end{document}


                                  enter image description here






                                  share|improve this answer






























                                    2














                                    Here I use stackengine instead of tikz. I create the macro wstack with a comma separated list to stack. The term wboxstrut defines the minimum vertical footprint of the stacked items, initially set to the footprint of w and later changed to strut, which will have the effect of aligning all box edges.



                                    Automatically adjusts to content width.



                                    It uses fboxrule and fboxsep to define the box rule and offset.



                                    documentclass{article}
                                    usepackage{stackengine,listofitems}
                                    defwboxwidth{.7em}
                                    defwboxstrut{vphantom{w}}
                                    newcommandwbox[1]{fbox{makebox[wboxwidth]{#1wboxstrut}}}
                                    newcommandwstack[1]{%
                                    setsepchar{,}%
                                    setstackEOL{,}%
                                    savestacktmp{Shortstack{#1}}%
                                    defwboxwidth{wdtmpcontent}%
                                    readlistboxitems{#1}%
                                    savestackboxbuild{wbox{boxitems[-1]}}%
                                    foreachitemxinboxitems{%
                                    ifnumxcnt=1relaxelse%
                                    savestackboxbuild{stackon[-fboxrule]{boxbuild}{wbox{boxitems[-xcnt]}}}%
                                    fi%
                                    }%
                                    boxbuild%
                                    }
                                    begin{document}
                                    wstack{,a,b,c,d}
                                    wstack{,a,b,c}
                                    wstack{b,c,d}
                                    wstack{,aaa,b,c,d}qquad
                                    defwboxstrut{strut}
                                    wstack{,a,b,c,d}
                                    wstack{,a,b,c}
                                    wstack{b,c,d}
                                    wstack{,aaa,b,c,d}
                                    end{document}


                                    enter image description here






                                    share|improve this answer




























                                      2












                                      2








                                      2







                                      Here I use stackengine instead of tikz. I create the macro wstack with a comma separated list to stack. The term wboxstrut defines the minimum vertical footprint of the stacked items, initially set to the footprint of w and later changed to strut, which will have the effect of aligning all box edges.



                                      Automatically adjusts to content width.



                                      It uses fboxrule and fboxsep to define the box rule and offset.



                                      documentclass{article}
                                      usepackage{stackengine,listofitems}
                                      defwboxwidth{.7em}
                                      defwboxstrut{vphantom{w}}
                                      newcommandwbox[1]{fbox{makebox[wboxwidth]{#1wboxstrut}}}
                                      newcommandwstack[1]{%
                                      setsepchar{,}%
                                      setstackEOL{,}%
                                      savestacktmp{Shortstack{#1}}%
                                      defwboxwidth{wdtmpcontent}%
                                      readlistboxitems{#1}%
                                      savestackboxbuild{wbox{boxitems[-1]}}%
                                      foreachitemxinboxitems{%
                                      ifnumxcnt=1relaxelse%
                                      savestackboxbuild{stackon[-fboxrule]{boxbuild}{wbox{boxitems[-xcnt]}}}%
                                      fi%
                                      }%
                                      boxbuild%
                                      }
                                      begin{document}
                                      wstack{,a,b,c,d}
                                      wstack{,a,b,c}
                                      wstack{b,c,d}
                                      wstack{,aaa,b,c,d}qquad
                                      defwboxstrut{strut}
                                      wstack{,a,b,c,d}
                                      wstack{,a,b,c}
                                      wstack{b,c,d}
                                      wstack{,aaa,b,c,d}
                                      end{document}


                                      enter image description here






                                      share|improve this answer















                                      Here I use stackengine instead of tikz. I create the macro wstack with a comma separated list to stack. The term wboxstrut defines the minimum vertical footprint of the stacked items, initially set to the footprint of w and later changed to strut, which will have the effect of aligning all box edges.



                                      Automatically adjusts to content width.



                                      It uses fboxrule and fboxsep to define the box rule and offset.



                                      documentclass{article}
                                      usepackage{stackengine,listofitems}
                                      defwboxwidth{.7em}
                                      defwboxstrut{vphantom{w}}
                                      newcommandwbox[1]{fbox{makebox[wboxwidth]{#1wboxstrut}}}
                                      newcommandwstack[1]{%
                                      setsepchar{,}%
                                      setstackEOL{,}%
                                      savestacktmp{Shortstack{#1}}%
                                      defwboxwidth{wdtmpcontent}%
                                      readlistboxitems{#1}%
                                      savestackboxbuild{wbox{boxitems[-1]}}%
                                      foreachitemxinboxitems{%
                                      ifnumxcnt=1relaxelse%
                                      savestackboxbuild{stackon[-fboxrule]{boxbuild}{wbox{boxitems[-xcnt]}}}%
                                      fi%
                                      }%
                                      boxbuild%
                                      }
                                      begin{document}
                                      wstack{,a,b,c,d}
                                      wstack{,a,b,c}
                                      wstack{b,c,d}
                                      wstack{,aaa,b,c,d}qquad
                                      defwboxstrut{strut}
                                      wstack{,a,b,c,d}
                                      wstack{,a,b,c}
                                      wstack{b,c,d}
                                      wstack{,aaa,b,c,d}
                                      end{document}


                                      enter image description here







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Dec 10 '18 at 12:22

























                                      answered Dec 10 '18 at 12:09









                                      Steven B. SegletesSteven B. Segletes

                                      153k9193402




                                      153k9193402






























                                          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%2f463378%2fdrawing-stacks-side-by-side-in-latex%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

                                          Wiesbaden

                                          Marschland

                                          Dieringhausen