Tikzpicture with remember picture and overlay inserting vertical space
up vote
4
down vote
favorite
I am trying to insert additional vertical space at the top, but instead this vertical space is inserted after the first title line:
However, if I comment out TikzDecorations[2]
, I obtain the correct spacing.
The desired output is has the vertical space before the first title line:
Update:
- A simpler test case is now provided which does not use
parshape
.
Notes:
The code below seems a bit long, but the relevant macro is
TypesetTitle
and the fact thatTikzDecorations
is invoked.In the MWE one solution is to move the
TikzDecorations
to be after the text, but in my actual use case I would prefer to have it first so I don't have to deal with the opacity/foreground/background issues.
References:
Why does vspace*{0pt} add vertical space?.
Curious about TikZ [remember picture,overlay] spacing seems like an almost exact match but don't think that is the case here.
Tikzpicture with overlay takes up space also seems like an exact match, but egreg's solution there recommends embedding thetikzpicture
at the beginning of the paragraph and that is the case here (AFAIK).- The solution presented at tikzpicture without leaving vertical mode also does not appear to work for this MWE.
Code: Simpler Test Case
documentclass{article}
usepackage{showframe}
usepackage{xparse}
usepackage{tikz}
usepackage{layout}
usepackage[textwidth=5.0cm]{geometry}
newcommand*{Text}{%
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.%
}%
newcommand*{MyAboveSkip}{5pt}
newcommand*{MyBotSkip}{5pt}
newcommand*{TypesetTitle}[1]{%
%% See comments in https://tex.stackexchange.com/q/7676/4301
hbox{}kern-topskip
vspace*{MyAboveSkip}
{bfseriescentering#1par}%
vspace*{MyBotSkip}%
}%
NewDocumentCommand{TikzDecorations}{%
O{2}% #1 = Number of lines for title
}{%
noindent
begin{tikzpicture}[remember picture,overlay]
coordinate (X) at ([
xshift=1.0in+hoffset+oddsidemargin,
yshift=-1.0in-voffset-topmargin-headheight-headsep%
]current page.north west);
draw [red] ([yshift=-2baselineskip-MyAboveSkip-MyBotSkip]X) -- ++ (linewidth,0);
end{tikzpicture}%
}
begin{document}%layout
TikzDecorations[2]
sloppyparskip0ptrelax
TypesetTitle{A Long Title That Requires Two Lines}%
noindentText
end{document}
Code: Full Test Case
documentclass{article}
usepackage{showframe}
usepackage{xparse}
usepackage{tikz}
usepackage{layout}
newcommand*{Text}{%
sloppynoindent
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum
gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem.
Nulla et lectus vestibulum urna fringilla ultrices.%
}%
newcommand*{TitleParShape}{%
0.40hsize 0.20hsize
0.35hsize 0.30hsize
}%
newcommand*{BodyParShape}{%
0.30hsize 0.40hsize
0.25hsize 0.50hsize
0.20hsize 0.60hsize
0.15hsize 0.70hsize
0.10hsize 0.80hsize
0.05hsize 0.90hsize
0.00hsize 1.00hsize
}%
newcommand*{NumberOfLines}{7 }
newcommand*{MyParShape}{%
parshape NumberOfLines
BodyParShape
}%
newcommand*{MyAboveSkip}{5pt}
newcommand*{MyBotSkip}{5pt}
newcommand*{TypesetTitle}[1]{%
%% See comments in https://tex.stackexchange.com/q/7676/4301
hbox{}kern-topskip
vspace*{MyAboveSkip}
parshape 2
TitleParShape
{bfseriescentering#1par}%
vspace*{MyBotSkip}%
}%
NewDocumentCommand{TikzDecorations}{%
O{2}% #1 = Number of lines for title
}{%
noindent
begin{tikzpicture}[remember picture,overlay]
coordinate (X) at ([
xshift=1.0in+hoffset+oddsidemargin,
yshift=-1.0in-voffset-topmargin-headheight-headsep%
]current page.north west);
draw [red] ([yshift=-2baselineskip-MyAboveSkip-MyBotSkip]X) -- ++ (linewidth,0);
end{tikzpicture}%
}
begin{document}%layout
TikzDecorations[2]
sloppyparskip0ptrelax
TypesetTitle{Two Line Title}%
MyParShape
Text
end{document}
tikz-pgf spacing vertical-alignment line-spacing
This question has an open bounty worth +100
reputation from Peter Grill ending in 7 days.
This question has not received enough attention.
add a comment |
up vote
4
down vote
favorite
I am trying to insert additional vertical space at the top, but instead this vertical space is inserted after the first title line:
However, if I comment out TikzDecorations[2]
, I obtain the correct spacing.
The desired output is has the vertical space before the first title line:
Update:
- A simpler test case is now provided which does not use
parshape
.
Notes:
The code below seems a bit long, but the relevant macro is
TypesetTitle
and the fact thatTikzDecorations
is invoked.In the MWE one solution is to move the
TikzDecorations
to be after the text, but in my actual use case I would prefer to have it first so I don't have to deal with the opacity/foreground/background issues.
References:
Why does vspace*{0pt} add vertical space?.
Curious about TikZ [remember picture,overlay] spacing seems like an almost exact match but don't think that is the case here.
Tikzpicture with overlay takes up space also seems like an exact match, but egreg's solution there recommends embedding thetikzpicture
at the beginning of the paragraph and that is the case here (AFAIK).- The solution presented at tikzpicture without leaving vertical mode also does not appear to work for this MWE.
Code: Simpler Test Case
documentclass{article}
usepackage{showframe}
usepackage{xparse}
usepackage{tikz}
usepackage{layout}
usepackage[textwidth=5.0cm]{geometry}
newcommand*{Text}{%
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.%
}%
newcommand*{MyAboveSkip}{5pt}
newcommand*{MyBotSkip}{5pt}
newcommand*{TypesetTitle}[1]{%
%% See comments in https://tex.stackexchange.com/q/7676/4301
hbox{}kern-topskip
vspace*{MyAboveSkip}
{bfseriescentering#1par}%
vspace*{MyBotSkip}%
}%
NewDocumentCommand{TikzDecorations}{%
O{2}% #1 = Number of lines for title
}{%
noindent
begin{tikzpicture}[remember picture,overlay]
coordinate (X) at ([
xshift=1.0in+hoffset+oddsidemargin,
yshift=-1.0in-voffset-topmargin-headheight-headsep%
]current page.north west);
draw [red] ([yshift=-2baselineskip-MyAboveSkip-MyBotSkip]X) -- ++ (linewidth,0);
end{tikzpicture}%
}
begin{document}%layout
TikzDecorations[2]
sloppyparskip0ptrelax
TypesetTitle{A Long Title That Requires Two Lines}%
noindentText
end{document}
Code: Full Test Case
documentclass{article}
usepackage{showframe}
usepackage{xparse}
usepackage{tikz}
usepackage{layout}
newcommand*{Text}{%
sloppynoindent
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum
gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem.
Nulla et lectus vestibulum urna fringilla ultrices.%
}%
newcommand*{TitleParShape}{%
0.40hsize 0.20hsize
0.35hsize 0.30hsize
}%
newcommand*{BodyParShape}{%
0.30hsize 0.40hsize
0.25hsize 0.50hsize
0.20hsize 0.60hsize
0.15hsize 0.70hsize
0.10hsize 0.80hsize
0.05hsize 0.90hsize
0.00hsize 1.00hsize
}%
newcommand*{NumberOfLines}{7 }
newcommand*{MyParShape}{%
parshape NumberOfLines
BodyParShape
}%
newcommand*{MyAboveSkip}{5pt}
newcommand*{MyBotSkip}{5pt}
newcommand*{TypesetTitle}[1]{%
%% See comments in https://tex.stackexchange.com/q/7676/4301
hbox{}kern-topskip
vspace*{MyAboveSkip}
parshape 2
TitleParShape
{bfseriescentering#1par}%
vspace*{MyBotSkip}%
}%
NewDocumentCommand{TikzDecorations}{%
O{2}% #1 = Number of lines for title
}{%
noindent
begin{tikzpicture}[remember picture,overlay]
coordinate (X) at ([
xshift=1.0in+hoffset+oddsidemargin,
yshift=-1.0in-voffset-topmargin-headheight-headsep%
]current page.north west);
draw [red] ([yshift=-2baselineskip-MyAboveSkip-MyBotSkip]X) -- ++ (linewidth,0);
end{tikzpicture}%
}
begin{document}%layout
TikzDecorations[2]
sloppyparskip0ptrelax
TypesetTitle{Two Line Title}%
MyParShape
Text
end{document}
tikz-pgf spacing vertical-alignment line-spacing
This question has an open bounty worth +100
reputation from Peter Grill ending in 7 days.
This question has not received enough attention.
I am not sure what you are aiming to, but you may consider thetcolorbox
package which is very powerful and versatile.
– DRi
yesterday
@DRi: I haven't found a way to usetcolorbox
with a customparshape
. I need the frame border to be along the parshape, not rectangular.
– Peter Grill
yesterday
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I am trying to insert additional vertical space at the top, but instead this vertical space is inserted after the first title line:
However, if I comment out TikzDecorations[2]
, I obtain the correct spacing.
The desired output is has the vertical space before the first title line:
Update:
- A simpler test case is now provided which does not use
parshape
.
Notes:
The code below seems a bit long, but the relevant macro is
TypesetTitle
and the fact thatTikzDecorations
is invoked.In the MWE one solution is to move the
TikzDecorations
to be after the text, but in my actual use case I would prefer to have it first so I don't have to deal with the opacity/foreground/background issues.
References:
Why does vspace*{0pt} add vertical space?.
Curious about TikZ [remember picture,overlay] spacing seems like an almost exact match but don't think that is the case here.
Tikzpicture with overlay takes up space also seems like an exact match, but egreg's solution there recommends embedding thetikzpicture
at the beginning of the paragraph and that is the case here (AFAIK).- The solution presented at tikzpicture without leaving vertical mode also does not appear to work for this MWE.
Code: Simpler Test Case
documentclass{article}
usepackage{showframe}
usepackage{xparse}
usepackage{tikz}
usepackage{layout}
usepackage[textwidth=5.0cm]{geometry}
newcommand*{Text}{%
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.%
}%
newcommand*{MyAboveSkip}{5pt}
newcommand*{MyBotSkip}{5pt}
newcommand*{TypesetTitle}[1]{%
%% See comments in https://tex.stackexchange.com/q/7676/4301
hbox{}kern-topskip
vspace*{MyAboveSkip}
{bfseriescentering#1par}%
vspace*{MyBotSkip}%
}%
NewDocumentCommand{TikzDecorations}{%
O{2}% #1 = Number of lines for title
}{%
noindent
begin{tikzpicture}[remember picture,overlay]
coordinate (X) at ([
xshift=1.0in+hoffset+oddsidemargin,
yshift=-1.0in-voffset-topmargin-headheight-headsep%
]current page.north west);
draw [red] ([yshift=-2baselineskip-MyAboveSkip-MyBotSkip]X) -- ++ (linewidth,0);
end{tikzpicture}%
}
begin{document}%layout
TikzDecorations[2]
sloppyparskip0ptrelax
TypesetTitle{A Long Title That Requires Two Lines}%
noindentText
end{document}
Code: Full Test Case
documentclass{article}
usepackage{showframe}
usepackage{xparse}
usepackage{tikz}
usepackage{layout}
newcommand*{Text}{%
sloppynoindent
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum
gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem.
Nulla et lectus vestibulum urna fringilla ultrices.%
}%
newcommand*{TitleParShape}{%
0.40hsize 0.20hsize
0.35hsize 0.30hsize
}%
newcommand*{BodyParShape}{%
0.30hsize 0.40hsize
0.25hsize 0.50hsize
0.20hsize 0.60hsize
0.15hsize 0.70hsize
0.10hsize 0.80hsize
0.05hsize 0.90hsize
0.00hsize 1.00hsize
}%
newcommand*{NumberOfLines}{7 }
newcommand*{MyParShape}{%
parshape NumberOfLines
BodyParShape
}%
newcommand*{MyAboveSkip}{5pt}
newcommand*{MyBotSkip}{5pt}
newcommand*{TypesetTitle}[1]{%
%% See comments in https://tex.stackexchange.com/q/7676/4301
hbox{}kern-topskip
vspace*{MyAboveSkip}
parshape 2
TitleParShape
{bfseriescentering#1par}%
vspace*{MyBotSkip}%
}%
NewDocumentCommand{TikzDecorations}{%
O{2}% #1 = Number of lines for title
}{%
noindent
begin{tikzpicture}[remember picture,overlay]
coordinate (X) at ([
xshift=1.0in+hoffset+oddsidemargin,
yshift=-1.0in-voffset-topmargin-headheight-headsep%
]current page.north west);
draw [red] ([yshift=-2baselineskip-MyAboveSkip-MyBotSkip]X) -- ++ (linewidth,0);
end{tikzpicture}%
}
begin{document}%layout
TikzDecorations[2]
sloppyparskip0ptrelax
TypesetTitle{Two Line Title}%
MyParShape
Text
end{document}
tikz-pgf spacing vertical-alignment line-spacing
I am trying to insert additional vertical space at the top, but instead this vertical space is inserted after the first title line:
However, if I comment out TikzDecorations[2]
, I obtain the correct spacing.
The desired output is has the vertical space before the first title line:
Update:
- A simpler test case is now provided which does not use
parshape
.
Notes:
The code below seems a bit long, but the relevant macro is
TypesetTitle
and the fact thatTikzDecorations
is invoked.In the MWE one solution is to move the
TikzDecorations
to be after the text, but in my actual use case I would prefer to have it first so I don't have to deal with the opacity/foreground/background issues.
References:
Why does vspace*{0pt} add vertical space?.
Curious about TikZ [remember picture,overlay] spacing seems like an almost exact match but don't think that is the case here.
Tikzpicture with overlay takes up space also seems like an exact match, but egreg's solution there recommends embedding thetikzpicture
at the beginning of the paragraph and that is the case here (AFAIK).- The solution presented at tikzpicture without leaving vertical mode also does not appear to work for this MWE.
Code: Simpler Test Case
documentclass{article}
usepackage{showframe}
usepackage{xparse}
usepackage{tikz}
usepackage{layout}
usepackage[textwidth=5.0cm]{geometry}
newcommand*{Text}{%
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.%
}%
newcommand*{MyAboveSkip}{5pt}
newcommand*{MyBotSkip}{5pt}
newcommand*{TypesetTitle}[1]{%
%% See comments in https://tex.stackexchange.com/q/7676/4301
hbox{}kern-topskip
vspace*{MyAboveSkip}
{bfseriescentering#1par}%
vspace*{MyBotSkip}%
}%
NewDocumentCommand{TikzDecorations}{%
O{2}% #1 = Number of lines for title
}{%
noindent
begin{tikzpicture}[remember picture,overlay]
coordinate (X) at ([
xshift=1.0in+hoffset+oddsidemargin,
yshift=-1.0in-voffset-topmargin-headheight-headsep%
]current page.north west);
draw [red] ([yshift=-2baselineskip-MyAboveSkip-MyBotSkip]X) -- ++ (linewidth,0);
end{tikzpicture}%
}
begin{document}%layout
TikzDecorations[2]
sloppyparskip0ptrelax
TypesetTitle{A Long Title That Requires Two Lines}%
noindentText
end{document}
Code: Full Test Case
documentclass{article}
usepackage{showframe}
usepackage{xparse}
usepackage{tikz}
usepackage{layout}
newcommand*{Text}{%
sloppynoindent
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum
gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem.
Nulla et lectus vestibulum urna fringilla ultrices.%
}%
newcommand*{TitleParShape}{%
0.40hsize 0.20hsize
0.35hsize 0.30hsize
}%
newcommand*{BodyParShape}{%
0.30hsize 0.40hsize
0.25hsize 0.50hsize
0.20hsize 0.60hsize
0.15hsize 0.70hsize
0.10hsize 0.80hsize
0.05hsize 0.90hsize
0.00hsize 1.00hsize
}%
newcommand*{NumberOfLines}{7 }
newcommand*{MyParShape}{%
parshape NumberOfLines
BodyParShape
}%
newcommand*{MyAboveSkip}{5pt}
newcommand*{MyBotSkip}{5pt}
newcommand*{TypesetTitle}[1]{%
%% See comments in https://tex.stackexchange.com/q/7676/4301
hbox{}kern-topskip
vspace*{MyAboveSkip}
parshape 2
TitleParShape
{bfseriescentering#1par}%
vspace*{MyBotSkip}%
}%
NewDocumentCommand{TikzDecorations}{%
O{2}% #1 = Number of lines for title
}{%
noindent
begin{tikzpicture}[remember picture,overlay]
coordinate (X) at ([
xshift=1.0in+hoffset+oddsidemargin,
yshift=-1.0in-voffset-topmargin-headheight-headsep%
]current page.north west);
draw [red] ([yshift=-2baselineskip-MyAboveSkip-MyBotSkip]X) -- ++ (linewidth,0);
end{tikzpicture}%
}
begin{document}%layout
TikzDecorations[2]
sloppyparskip0ptrelax
TypesetTitle{Two Line Title}%
MyParShape
Text
end{document}
tikz-pgf spacing vertical-alignment line-spacing
tikz-pgf spacing vertical-alignment line-spacing
edited yesterday
asked 2 days ago
Peter Grill
163k24432740
163k24432740
This question has an open bounty worth +100
reputation from Peter Grill ending in 7 days.
This question has not received enough attention.
This question has an open bounty worth +100
reputation from Peter Grill ending in 7 days.
This question has not received enough attention.
I am not sure what you are aiming to, but you may consider thetcolorbox
package which is very powerful and versatile.
– DRi
yesterday
@DRi: I haven't found a way to usetcolorbox
with a customparshape
. I need the frame border to be along the parshape, not rectangular.
– Peter Grill
yesterday
add a comment |
I am not sure what you are aiming to, but you may consider thetcolorbox
package which is very powerful and versatile.
– DRi
yesterday
@DRi: I haven't found a way to usetcolorbox
with a customparshape
. I need the frame border to be along the parshape, not rectangular.
– Peter Grill
yesterday
I am not sure what you are aiming to, but you may consider the
tcolorbox
package which is very powerful and versatile.– DRi
yesterday
I am not sure what you are aiming to, but you may consider the
tcolorbox
package which is very powerful and versatile.– DRi
yesterday
@DRi: I haven't found a way to use
tcolorbox
with a custom parshape
. I need the frame border to be along the parshape, not rectangular.– Peter Grill
yesterday
@DRi: I haven't found a way to use
tcolorbox
with a custom parshape
. I need the frame border to be along the parshape, not rectangular.– Peter Grill
yesterday
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f460886%2ftikzpicture-with-remember-picture-and-overlay-inserting-vertical-space%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
I am not sure what you are aiming to, but you may consider the
tcolorbox
package which is very powerful and versatile.– DRi
yesterday
@DRi: I haven't found a way to use
tcolorbox
with a customparshape
. I need the frame border to be along the parshape, not rectangular.– Peter Grill
yesterday