Align the baselines of two nodes placed side by side










8















I have the following code with two nodes:



documentclass[crop,tikz]standalone
begindocument

usetikzlibrarypositioning,calc
tikzstyleblock = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]

begintikzpicture
node [block,align=center](A) shortstackdouble \ type ;
node [block,align=center,right=1.5cm of A](B) shortstacksingle \ type ;

endtikzpicture
enddocument


Because the content of node A has no "long" character that ranges below the baseline, the distance between the two lines is closer than in the second node B. There, the "g" character ranges below the baseline and therefore it seems that additional space is used and the two blocks are not aligned.



I could fix that by including a vphantomg into node A. However, that would make the line spacing large in both blocks.



Instead, I want that the line space is small, just as if there were no characters that range below the baseline.



Is it possible to somehow "ignore" these characters?










share|improve this question
























  • shortstacksinsmashgle \ type

    – Steven B. Segletes
    Nov 15 '18 at 20:45















8















I have the following code with two nodes:



documentclass[crop,tikz]standalone
begindocument

usetikzlibrarypositioning,calc
tikzstyleblock = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]

begintikzpicture
node [block,align=center](A) shortstackdouble \ type ;
node [block,align=center,right=1.5cm of A](B) shortstacksingle \ type ;

endtikzpicture
enddocument


Because the content of node A has no "long" character that ranges below the baseline, the distance between the two lines is closer than in the second node B. There, the "g" character ranges below the baseline and therefore it seems that additional space is used and the two blocks are not aligned.



I could fix that by including a vphantomg into node A. However, that would make the line spacing large in both blocks.



Instead, I want that the line space is small, just as if there were no characters that range below the baseline.



Is it possible to somehow "ignore" these characters?










share|improve this question
























  • shortstacksinsmashgle \ type

    – Steven B. Segletes
    Nov 15 '18 at 20:45













8












8








8


1






I have the following code with two nodes:



documentclass[crop,tikz]standalone
begindocument

usetikzlibrarypositioning,calc
tikzstyleblock = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]

begintikzpicture
node [block,align=center](A) shortstackdouble \ type ;
node [block,align=center,right=1.5cm of A](B) shortstacksingle \ type ;

endtikzpicture
enddocument


Because the content of node A has no "long" character that ranges below the baseline, the distance between the two lines is closer than in the second node B. There, the "g" character ranges below the baseline and therefore it seems that additional space is used and the two blocks are not aligned.



I could fix that by including a vphantomg into node A. However, that would make the line spacing large in both blocks.



Instead, I want that the line space is small, just as if there were no characters that range below the baseline.



Is it possible to somehow "ignore" these characters?










share|improve this question
















I have the following code with two nodes:



documentclass[crop,tikz]standalone
begindocument

usetikzlibrarypositioning,calc
tikzstyleblock = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]

begintikzpicture
node [block,align=center](A) shortstackdouble \ type ;
node [block,align=center,right=1.5cm of A](B) shortstacksingle \ type ;

endtikzpicture
enddocument


Because the content of node A has no "long" character that ranges below the baseline, the distance between the two lines is closer than in the second node B. There, the "g" character ranges below the baseline and therefore it seems that additional space is used and the two blocks are not aligned.



I could fix that by including a vphantomg into node A. However, that would make the line spacing large in both blocks.



Instead, I want that the line space is small, just as if there were no characters that range below the baseline.



Is it possible to somehow "ignore" these characters?







tikz-pgf shortstack






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 17 '18 at 19:32









AndréC

10.2k11547




10.2k11547










asked Nov 15 '18 at 20:35









SampleTimeSampleTime

24217




24217












  • shortstacksinsmashgle \ type

    – Steven B. Segletes
    Nov 15 '18 at 20:45

















  • shortstacksinsmashgle \ type

    – Steven B. Segletes
    Nov 15 '18 at 20:45
















shortstacksinsmashgle \ type

– Steven B. Segletes
Nov 15 '18 at 20:45





shortstacksinsmashgle \ type

– Steven B. Segletes
Nov 15 '18 at 20:45










3 Answers
3






active

oldest

votes


















8














You should just smash the [b]aseline of those words/phrases:



enter image description here



documentclassarticle

usepackagetikz,amsmath

begindocument

usetikzlibrarypositioning,calc
tikzstyleblock = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]

begintikzpicture
node [block,align=center](A) shortstackdouble \ type;
node [block,align=center,right=1.5cm of A](B) shortstacksmash[b]single \ type;
endtikzpicture

enddocument


amsmath provides the extended version of smash.






share|improve this answer























  • +1 This is the first time I've seen this smash command, can you give me more details about it?

    – AndréC
    Nov 15 '18 at 20:53






  • 3





    See this code and its associated output. smash removes the height and depth of its argument, while smash[b]/smash[t] removes only the depth/height.

    – Werner
    Nov 15 '18 at 21:00


















8














Another method is to use the NextLine macro instead of \. This eliminates the need to go back and change things just because you changed the text:



enter image description here



References



  • How to make mdframed ignore descenders in last line

Code:



documentclass[crop,tikz, border=2pt]standalone
begindocument

%% https://tex.stackexchange.com/a/51406/4301
newcommand*IgnodeDescenders-dimexprdpstrutbox+baselineskip
newcommand*NextLinestrut\[IgnodeDescenders]

usetikzlibrarypositioning,calc
tikzstyleblock = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]

begintikzpicture
node [block,align=center](A) shortstackdoubleNextLine type;
node [block,align=center,right=1.5cm of A](B) shortstacksingleNextLine type;

endtikzpicture
enddocument





share|improve this answer























  • Somehow, when I tested this, it seems that the NewLine-line is larger than the "standard" line... If I replace the NewLine command in the A node with \, then distance of both lines is smaller although it should be the same?

    – SampleTime
    Nov 15 '18 at 22:25


















6














This is discussed at length in the pgfmanual on p. 65. The upshot is that you can add a suitable text depth.



documentclass[crop,tikz]standalone
begindocument

usetikzlibrarypositioning,calc
tikzsetblock/.style=draw, rectangle, minimum height=1cm, minimum width=1cm,
outer sep=0pt,text height=3ex,text depth=.25ex

begintikzpicture
node [block,align=center](A) double \ type ;
node [block,align=center,right=1.5cm of A](B) single \ type ;
draw[red] (A.west) -- (B.east);
endtikzpicture
enddocument


enter image description here



The red line is only to guide the eye.






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%2f460191%2falign-the-baselines-of-two-nodes-placed-side-by-side%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    8














    You should just smash the [b]aseline of those words/phrases:



    enter image description here



    documentclassarticle

    usepackagetikz,amsmath

    begindocument

    usetikzlibrarypositioning,calc
    tikzstyleblock = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]

    begintikzpicture
    node [block,align=center](A) shortstackdouble \ type;
    node [block,align=center,right=1.5cm of A](B) shortstacksmash[b]single \ type;
    endtikzpicture

    enddocument


    amsmath provides the extended version of smash.






    share|improve this answer























    • +1 This is the first time I've seen this smash command, can you give me more details about it?

      – AndréC
      Nov 15 '18 at 20:53






    • 3





      See this code and its associated output. smash removes the height and depth of its argument, while smash[b]/smash[t] removes only the depth/height.

      – Werner
      Nov 15 '18 at 21:00















    8














    You should just smash the [b]aseline of those words/phrases:



    enter image description here



    documentclassarticle

    usepackagetikz,amsmath

    begindocument

    usetikzlibrarypositioning,calc
    tikzstyleblock = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]

    begintikzpicture
    node [block,align=center](A) shortstackdouble \ type;
    node [block,align=center,right=1.5cm of A](B) shortstacksmash[b]single \ type;
    endtikzpicture

    enddocument


    amsmath provides the extended version of smash.






    share|improve this answer























    • +1 This is the first time I've seen this smash command, can you give me more details about it?

      – AndréC
      Nov 15 '18 at 20:53






    • 3





      See this code and its associated output. smash removes the height and depth of its argument, while smash[b]/smash[t] removes only the depth/height.

      – Werner
      Nov 15 '18 at 21:00













    8












    8








    8







    You should just smash the [b]aseline of those words/phrases:



    enter image description here



    documentclassarticle

    usepackagetikz,amsmath

    begindocument

    usetikzlibrarypositioning,calc
    tikzstyleblock = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]

    begintikzpicture
    node [block,align=center](A) shortstackdouble \ type;
    node [block,align=center,right=1.5cm of A](B) shortstacksmash[b]single \ type;
    endtikzpicture

    enddocument


    amsmath provides the extended version of smash.






    share|improve this answer













    You should just smash the [b]aseline of those words/phrases:



    enter image description here



    documentclassarticle

    usepackagetikz,amsmath

    begindocument

    usetikzlibrarypositioning,calc
    tikzstyleblock = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]

    begintikzpicture
    node [block,align=center](A) shortstackdouble \ type;
    node [block,align=center,right=1.5cm of A](B) shortstacksmash[b]single \ type;
    endtikzpicture

    enddocument


    amsmath provides the extended version of smash.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 15 '18 at 20:47









    WernerWerner

    447k699891695




    447k699891695












    • +1 This is the first time I've seen this smash command, can you give me more details about it?

      – AndréC
      Nov 15 '18 at 20:53






    • 3





      See this code and its associated output. smash removes the height and depth of its argument, while smash[b]/smash[t] removes only the depth/height.

      – Werner
      Nov 15 '18 at 21:00

















    • +1 This is the first time I've seen this smash command, can you give me more details about it?

      – AndréC
      Nov 15 '18 at 20:53






    • 3





      See this code and its associated output. smash removes the height and depth of its argument, while smash[b]/smash[t] removes only the depth/height.

      – Werner
      Nov 15 '18 at 21:00
















    +1 This is the first time I've seen this smash command, can you give me more details about it?

    – AndréC
    Nov 15 '18 at 20:53





    +1 This is the first time I've seen this smash command, can you give me more details about it?

    – AndréC
    Nov 15 '18 at 20:53




    3




    3





    See this code and its associated output. smash removes the height and depth of its argument, while smash[b]/smash[t] removes only the depth/height.

    – Werner
    Nov 15 '18 at 21:00





    See this code and its associated output. smash removes the height and depth of its argument, while smash[b]/smash[t] removes only the depth/height.

    – Werner
    Nov 15 '18 at 21:00











    8














    Another method is to use the NextLine macro instead of \. This eliminates the need to go back and change things just because you changed the text:



    enter image description here



    References



    • How to make mdframed ignore descenders in last line

    Code:



    documentclass[crop,tikz, border=2pt]standalone
    begindocument

    %% https://tex.stackexchange.com/a/51406/4301
    newcommand*IgnodeDescenders-dimexprdpstrutbox+baselineskip
    newcommand*NextLinestrut\[IgnodeDescenders]

    usetikzlibrarypositioning,calc
    tikzstyleblock = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]

    begintikzpicture
    node [block,align=center](A) shortstackdoubleNextLine type;
    node [block,align=center,right=1.5cm of A](B) shortstacksingleNextLine type;

    endtikzpicture
    enddocument





    share|improve this answer























    • Somehow, when I tested this, it seems that the NewLine-line is larger than the "standard" line... If I replace the NewLine command in the A node with \, then distance of both lines is smaller although it should be the same?

      – SampleTime
      Nov 15 '18 at 22:25















    8














    Another method is to use the NextLine macro instead of \. This eliminates the need to go back and change things just because you changed the text:



    enter image description here



    References



    • How to make mdframed ignore descenders in last line

    Code:



    documentclass[crop,tikz, border=2pt]standalone
    begindocument

    %% https://tex.stackexchange.com/a/51406/4301
    newcommand*IgnodeDescenders-dimexprdpstrutbox+baselineskip
    newcommand*NextLinestrut\[IgnodeDescenders]

    usetikzlibrarypositioning,calc
    tikzstyleblock = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]

    begintikzpicture
    node [block,align=center](A) shortstackdoubleNextLine type;
    node [block,align=center,right=1.5cm of A](B) shortstacksingleNextLine type;

    endtikzpicture
    enddocument





    share|improve this answer























    • Somehow, when I tested this, it seems that the NewLine-line is larger than the "standard" line... If I replace the NewLine command in the A node with \, then distance of both lines is smaller although it should be the same?

      – SampleTime
      Nov 15 '18 at 22:25













    8












    8








    8







    Another method is to use the NextLine macro instead of \. This eliminates the need to go back and change things just because you changed the text:



    enter image description here



    References



    • How to make mdframed ignore descenders in last line

    Code:



    documentclass[crop,tikz, border=2pt]standalone
    begindocument

    %% https://tex.stackexchange.com/a/51406/4301
    newcommand*IgnodeDescenders-dimexprdpstrutbox+baselineskip
    newcommand*NextLinestrut\[IgnodeDescenders]

    usetikzlibrarypositioning,calc
    tikzstyleblock = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]

    begintikzpicture
    node [block,align=center](A) shortstackdoubleNextLine type;
    node [block,align=center,right=1.5cm of A](B) shortstacksingleNextLine type;

    endtikzpicture
    enddocument





    share|improve this answer













    Another method is to use the NextLine macro instead of \. This eliminates the need to go back and change things just because you changed the text:



    enter image description here



    References



    • How to make mdframed ignore descenders in last line

    Code:



    documentclass[crop,tikz, border=2pt]standalone
    begindocument

    %% https://tex.stackexchange.com/a/51406/4301
    newcommand*IgnodeDescenders-dimexprdpstrutbox+baselineskip
    newcommand*NextLinestrut\[IgnodeDescenders]

    usetikzlibrarypositioning,calc
    tikzstyleblock = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]

    begintikzpicture
    node [block,align=center](A) shortstackdoubleNextLine type;
    node [block,align=center,right=1.5cm of A](B) shortstacksingleNextLine type;

    endtikzpicture
    enddocument






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 15 '18 at 20:57









    Peter GrillPeter Grill

    166k25441756




    166k25441756












    • Somehow, when I tested this, it seems that the NewLine-line is larger than the "standard" line... If I replace the NewLine command in the A node with \, then distance of both lines is smaller although it should be the same?

      – SampleTime
      Nov 15 '18 at 22:25

















    • Somehow, when I tested this, it seems that the NewLine-line is larger than the "standard" line... If I replace the NewLine command in the A node with \, then distance of both lines is smaller although it should be the same?

      – SampleTime
      Nov 15 '18 at 22:25
















    Somehow, when I tested this, it seems that the NewLine-line is larger than the "standard" line... If I replace the NewLine command in the A node with \, then distance of both lines is smaller although it should be the same?

    – SampleTime
    Nov 15 '18 at 22:25





    Somehow, when I tested this, it seems that the NewLine-line is larger than the "standard" line... If I replace the NewLine command in the A node with \, then distance of both lines is smaller although it should be the same?

    – SampleTime
    Nov 15 '18 at 22:25











    6














    This is discussed at length in the pgfmanual on p. 65. The upshot is that you can add a suitable text depth.



    documentclass[crop,tikz]standalone
    begindocument

    usetikzlibrarypositioning,calc
    tikzsetblock/.style=draw, rectangle, minimum height=1cm, minimum width=1cm,
    outer sep=0pt,text height=3ex,text depth=.25ex

    begintikzpicture
    node [block,align=center](A) double \ type ;
    node [block,align=center,right=1.5cm of A](B) single \ type ;
    draw[red] (A.west) -- (B.east);
    endtikzpicture
    enddocument


    enter image description here



    The red line is only to guide the eye.






    share|improve this answer



























      6














      This is discussed at length in the pgfmanual on p. 65. The upshot is that you can add a suitable text depth.



      documentclass[crop,tikz]standalone
      begindocument

      usetikzlibrarypositioning,calc
      tikzsetblock/.style=draw, rectangle, minimum height=1cm, minimum width=1cm,
      outer sep=0pt,text height=3ex,text depth=.25ex

      begintikzpicture
      node [block,align=center](A) double \ type ;
      node [block,align=center,right=1.5cm of A](B) single \ type ;
      draw[red] (A.west) -- (B.east);
      endtikzpicture
      enddocument


      enter image description here



      The red line is only to guide the eye.






      share|improve this answer

























        6












        6








        6







        This is discussed at length in the pgfmanual on p. 65. The upshot is that you can add a suitable text depth.



        documentclass[crop,tikz]standalone
        begindocument

        usetikzlibrarypositioning,calc
        tikzsetblock/.style=draw, rectangle, minimum height=1cm, minimum width=1cm,
        outer sep=0pt,text height=3ex,text depth=.25ex

        begintikzpicture
        node [block,align=center](A) double \ type ;
        node [block,align=center,right=1.5cm of A](B) single \ type ;
        draw[red] (A.west) -- (B.east);
        endtikzpicture
        enddocument


        enter image description here



        The red line is only to guide the eye.






        share|improve this answer













        This is discussed at length in the pgfmanual on p. 65. The upshot is that you can add a suitable text depth.



        documentclass[crop,tikz]standalone
        begindocument

        usetikzlibrarypositioning,calc
        tikzsetblock/.style=draw, rectangle, minimum height=1cm, minimum width=1cm,
        outer sep=0pt,text height=3ex,text depth=.25ex

        begintikzpicture
        node [block,align=center](A) double \ type ;
        node [block,align=center,right=1.5cm of A](B) single \ type ;
        draw[red] (A.west) -- (B.east);
        endtikzpicture
        enddocument


        enter image description here



        The red line is only to guide the eye.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 '18 at 20:55









        marmotmarmot

        107k5129244




        107k5129244



























            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%2f460191%2falign-the-baselines-of-two-nodes-placed-side-by-side%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

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            ReactJS Fetched API data displays live - need Data displayed static

            政党