Tikzpicture with remember picture and overlay inserting vertical space











up vote
4
down vote

favorite
2












I am trying to insert additional vertical space at the top, but instead this vertical space is inserted after the first title line:



enter image description here



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:



enter image description here



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 that TikzDecorations 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 the tikzpicture 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}









share|improve this question

















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 the tcolorboxpackage 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

















up vote
4
down vote

favorite
2












I am trying to insert additional vertical space at the top, but instead this vertical space is inserted after the first title line:



enter image description here



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:



enter image description here



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 that TikzDecorations 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 the tikzpicture 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}









share|improve this question

















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 the tcolorboxpackage 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















up vote
4
down vote

favorite
2









up vote
4
down vote

favorite
2






2





I am trying to insert additional vertical space at the top, but instead this vertical space is inserted after the first title line:



enter image description here



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:



enter image description here



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 that TikzDecorations 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 the tikzpicture 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}









share|improve this question















I am trying to insert additional vertical space at the top, but instead this vertical space is inserted after the first title line:



enter image description here



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:



enter image description here



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 that TikzDecorations 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 the tikzpicture 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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 the tcolorboxpackage 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




















  • I am not sure what you are aiming to, but you may consider the tcolorboxpackage 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


















I am not sure what you are aiming to, but you may consider the tcolorboxpackage which is very powerful and versatile.
– DRi
yesterday




I am not sure what you are aiming to, but you may consider the tcolorboxpackage 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

















active

oldest

votes











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',
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%2f460886%2ftikzpicture-with-remember-picture-and-overlay-inserting-vertical-space%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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

サソリ

広島県道265号伴広島線

Accessing regular linux commands in Huawei's Dopra Linux