Align the baselines of two nodes placed side by side
up vote
8
down vote
favorite
I have the following code with two nodes:
documentclass[crop,tikz]{standalone}
begin{document}
usetikzlibrary{positioning,calc}
tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
begin{tikzpicture}
node [block,align=center](A) { shortstack{double \ type} };
node [block,align=center,right=1.5cm of A](B) { shortstack{single \ type} };
end{tikzpicture}
end{document}
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 vphantom{g} 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
add a comment |
up vote
8
down vote
favorite
I have the following code with two nodes:
documentclass[crop,tikz]{standalone}
begin{document}
usetikzlibrary{positioning,calc}
tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
begin{tikzpicture}
node [block,align=center](A) { shortstack{double \ type} };
node [block,align=center,right=1.5cm of A](B) { shortstack{single \ type} };
end{tikzpicture}
end{document}
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 vphantom{g} 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
shortstack{sinsmash{g}le \ type}
– Steven B. Segletes
2 days ago
add a comment |
up vote
8
down vote
favorite
up vote
8
down vote
favorite
I have the following code with two nodes:
documentclass[crop,tikz]{standalone}
begin{document}
usetikzlibrary{positioning,calc}
tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
begin{tikzpicture}
node [block,align=center](A) { shortstack{double \ type} };
node [block,align=center,right=1.5cm of A](B) { shortstack{single \ type} };
end{tikzpicture}
end{document}
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 vphantom{g} 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
I have the following code with two nodes:
documentclass[crop,tikz]{standalone}
begin{document}
usetikzlibrary{positioning,calc}
tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
begin{tikzpicture}
node [block,align=center](A) { shortstack{double \ type} };
node [block,align=center,right=1.5cm of A](B) { shortstack{single \ type} };
end{tikzpicture}
end{document}
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 vphantom{g} 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
tikz-pgf shortstack
edited 8 hours ago
AndréC
5,7621937
5,7621937
asked 2 days ago
SampleTime
2426
2426
shortstack{sinsmash{g}le \ type}
– Steven B. Segletes
2 days ago
add a comment |
shortstack{sinsmash{g}le \ type}
– Steven B. Segletes
2 days ago
shortstack{sinsmash{g}le \ type}
– Steven B. Segletes
2 days ago
shortstack{sinsmash{g}le \ type}
– Steven B. Segletes
2 days ago
add a comment |
3 Answers
3
active
oldest
votes
up vote
8
down vote
accepted
You should just smash
the [b]
aseline of those words/phrases:
documentclass{article}
usepackage{tikz,amsmath}
begin{document}
usetikzlibrary{positioning,calc}
tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
begin{tikzpicture}
node [block,align=center](A) {shortstack{double \ type}};
node [block,align=center,right=1.5cm of A](B) {shortstack{smash[b]{single} \ type}};
end{tikzpicture}
end{document}
amsmath
provides the extended version of smash
.
+1 This is the first time I've seen thissmash
command, can you give me more details about it?
– AndréC
2 days ago
2
See this code and its associated output.smash
removes the height and depth of its argument, whilesmash[b]
/smash[t]
removes only the depth/height.
– Werner
2 days ago
add a comment |
up vote
8
down vote
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:
References
- How to make mdframed ignore descenders in last line
Code:
documentclass[crop,tikz, border=2pt]{standalone}
begin{document}
%% https://tex.stackexchange.com/a/51406/4301
newcommand*{IgnodeDescenders}{-dimexprdpstrutbox+baselineskip}
newcommand*{NextLine}{strut\[IgnodeDescenders]}
usetikzlibrary{positioning,calc}
tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
begin{tikzpicture}
node [block,align=center](A) {shortstack{doubleNextLine type}};
node [block,align=center,right=1.5cm of A](B) {shortstack{singleNextLine type}};
end{tikzpicture}
end{document}
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
2 days ago
add a comment |
up vote
6
down vote
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}
begin{document}
usetikzlibrary{positioning,calc}
tikzset{block/.style={draw, rectangle, minimum height=1cm, minimum width=1cm,
outer sep=0pt,text height=3ex,text depth=.25ex}}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
The red line is only to guide the eye.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
8
down vote
accepted
You should just smash
the [b]
aseline of those words/phrases:
documentclass{article}
usepackage{tikz,amsmath}
begin{document}
usetikzlibrary{positioning,calc}
tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
begin{tikzpicture}
node [block,align=center](A) {shortstack{double \ type}};
node [block,align=center,right=1.5cm of A](B) {shortstack{smash[b]{single} \ type}};
end{tikzpicture}
end{document}
amsmath
provides the extended version of smash
.
+1 This is the first time I've seen thissmash
command, can you give me more details about it?
– AndréC
2 days ago
2
See this code and its associated output.smash
removes the height and depth of its argument, whilesmash[b]
/smash[t]
removes only the depth/height.
– Werner
2 days ago
add a comment |
up vote
8
down vote
accepted
You should just smash
the [b]
aseline of those words/phrases:
documentclass{article}
usepackage{tikz,amsmath}
begin{document}
usetikzlibrary{positioning,calc}
tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
begin{tikzpicture}
node [block,align=center](A) {shortstack{double \ type}};
node [block,align=center,right=1.5cm of A](B) {shortstack{smash[b]{single} \ type}};
end{tikzpicture}
end{document}
amsmath
provides the extended version of smash
.
+1 This is the first time I've seen thissmash
command, can you give me more details about it?
– AndréC
2 days ago
2
See this code and its associated output.smash
removes the height and depth of its argument, whilesmash[b]
/smash[t]
removes only the depth/height.
– Werner
2 days ago
add a comment |
up vote
8
down vote
accepted
up vote
8
down vote
accepted
You should just smash
the [b]
aseline of those words/phrases:
documentclass{article}
usepackage{tikz,amsmath}
begin{document}
usetikzlibrary{positioning,calc}
tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
begin{tikzpicture}
node [block,align=center](A) {shortstack{double \ type}};
node [block,align=center,right=1.5cm of A](B) {shortstack{smash[b]{single} \ type}};
end{tikzpicture}
end{document}
amsmath
provides the extended version of smash
.
You should just smash
the [b]
aseline of those words/phrases:
documentclass{article}
usepackage{tikz,amsmath}
begin{document}
usetikzlibrary{positioning,calc}
tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
begin{tikzpicture}
node [block,align=center](A) {shortstack{double \ type}};
node [block,align=center,right=1.5cm of A](B) {shortstack{smash[b]{single} \ type}};
end{tikzpicture}
end{document}
amsmath
provides the extended version of smash
.
answered 2 days ago
Werner
430k599461623
430k599461623
+1 This is the first time I've seen thissmash
command, can you give me more details about it?
– AndréC
2 days ago
2
See this code and its associated output.smash
removes the height and depth of its argument, whilesmash[b]
/smash[t]
removes only the depth/height.
– Werner
2 days ago
add a comment |
+1 This is the first time I've seen thissmash
command, can you give me more details about it?
– AndréC
2 days ago
2
See this code and its associated output.smash
removes the height and depth of its argument, whilesmash[b]
/smash[t]
removes only the depth/height.
– Werner
2 days ago
+1 This is the first time I've seen this
smash
command, can you give me more details about it?– AndréC
2 days ago
+1 This is the first time I've seen this
smash
command, can you give me more details about it?– AndréC
2 days ago
2
2
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
2 days ago
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
2 days ago
add a comment |
up vote
8
down vote
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:
References
- How to make mdframed ignore descenders in last line
Code:
documentclass[crop,tikz, border=2pt]{standalone}
begin{document}
%% https://tex.stackexchange.com/a/51406/4301
newcommand*{IgnodeDescenders}{-dimexprdpstrutbox+baselineskip}
newcommand*{NextLine}{strut\[IgnodeDescenders]}
usetikzlibrary{positioning,calc}
tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
begin{tikzpicture}
node [block,align=center](A) {shortstack{doubleNextLine type}};
node [block,align=center,right=1.5cm of A](B) {shortstack{singleNextLine type}};
end{tikzpicture}
end{document}
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
2 days ago
add a comment |
up vote
8
down vote
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:
References
- How to make mdframed ignore descenders in last line
Code:
documentclass[crop,tikz, border=2pt]{standalone}
begin{document}
%% https://tex.stackexchange.com/a/51406/4301
newcommand*{IgnodeDescenders}{-dimexprdpstrutbox+baselineskip}
newcommand*{NextLine}{strut\[IgnodeDescenders]}
usetikzlibrary{positioning,calc}
tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
begin{tikzpicture}
node [block,align=center](A) {shortstack{doubleNextLine type}};
node [block,align=center,right=1.5cm of A](B) {shortstack{singleNextLine type}};
end{tikzpicture}
end{document}
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
2 days ago
add a comment |
up vote
8
down vote
up vote
8
down vote
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:
References
- How to make mdframed ignore descenders in last line
Code:
documentclass[crop,tikz, border=2pt]{standalone}
begin{document}
%% https://tex.stackexchange.com/a/51406/4301
newcommand*{IgnodeDescenders}{-dimexprdpstrutbox+baselineskip}
newcommand*{NextLine}{strut\[IgnodeDescenders]}
usetikzlibrary{positioning,calc}
tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
begin{tikzpicture}
node [block,align=center](A) {shortstack{doubleNextLine type}};
node [block,align=center,right=1.5cm of A](B) {shortstack{singleNextLine type}};
end{tikzpicture}
end{document}
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:
References
- How to make mdframed ignore descenders in last line
Code:
documentclass[crop,tikz, border=2pt]{standalone}
begin{document}
%% https://tex.stackexchange.com/a/51406/4301
newcommand*{IgnodeDescenders}{-dimexprdpstrutbox+baselineskip}
newcommand*{NextLine}{strut\[IgnodeDescenders]}
usetikzlibrary{positioning,calc}
tikzstyle{block} = [draw, rectangle, minimum height=1cm, minimum width=1cm, outer sep=0pt]
begin{tikzpicture}
node [block,align=center](A) {shortstack{doubleNextLine type}};
node [block,align=center,right=1.5cm of A](B) {shortstack{singleNextLine type}};
end{tikzpicture}
end{document}
answered 2 days ago
Peter Grill
163k24432740
163k24432740
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
2 days ago
add a comment |
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
2 days ago
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
2 days ago
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
2 days ago
add a comment |
up vote
6
down vote
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}
begin{document}
usetikzlibrary{positioning,calc}
tikzset{block/.style={draw, rectangle, minimum height=1cm, minimum width=1cm,
outer sep=0pt,text height=3ex,text depth=.25ex}}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
The red line is only to guide the eye.
add a comment |
up vote
6
down vote
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}
begin{document}
usetikzlibrary{positioning,calc}
tikzset{block/.style={draw, rectangle, minimum height=1cm, minimum width=1cm,
outer sep=0pt,text height=3ex,text depth=.25ex}}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
The red line is only to guide the eye.
add a comment |
up vote
6
down vote
up vote
6
down vote
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}
begin{document}
usetikzlibrary{positioning,calc}
tikzset{block/.style={draw, rectangle, minimum height=1cm, minimum width=1cm,
outer sep=0pt,text height=3ex,text depth=.25ex}}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
The red line is only to guide the eye.
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}
begin{document}
usetikzlibrary{positioning,calc}
tikzset{block/.style={draw, rectangle, minimum height=1cm, minimum width=1cm,
outer sep=0pt,text height=3ex,text depth=.25ex}}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
The red line is only to guide the eye.
answered 2 days ago
marmot
75.8k486160
75.8k486160
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
shortstack{sinsmash{g}le \ type}
– Steven B. Segletes
2 days ago