Drawing grid lines to show vertical position of text











up vote
2
down vote

favorite












I have text where I want to adjust the space above the first line. I want to overlay grid lines to show where the vertical position of the text is.



The MWE below with the following line commented is the standard output. The red horizontal lines are integer multiples of baselineskip from the top.



%defIncludeDesiredTopSkip{}


enter image description here



However, if I uncomment this line (which applies the DesiredTopSkip, which is set to 0pt here), I obtain the following:



defIncludeDesiredTopSkip{}


enter image description here



Note that the baseline now is exactly on the line.



Question:



What am I missing that would explain this discrepancy in the two cases and how do I get both cases to properly display the baseline?



Note:




  • In case anyone is curious as to why I want to do this: These lines are then used to compute the parshape parameters based on where these lines intersect the particular shape.


References:




  • Why does vspace*{0pt} add vertical space?.


  • Confused with TeX terminology: height, depth, width



Code:



%defIncludeDesiredTopSkip{}
documentclass{article}
usepackage{showframe}
usepackage{tikz}

usepackage[paperwidth=7.0cm]{geometry}

newcommand*{DesiredTopSkip}{0pt}

newcommand*{ShowTextGuideLines}[1]{%
begin{tikzpicture}[remember picture, overlay]
coordinate (X) at ([
xshift=1.0in+hoffset+oddsidemargin,
yshift=-1.0in-voffset-topmargin-headheight-headsep%
]current page.north west);

node [draw=red, fill=yellow] at (X) {X};%% DEBUGGING: Ensure (X) is the correct spot.

foreach X in {1, ..., #1} {%
draw [thin, red] ([yshift=-Xbaselineskip-DesiredTopSkip]X) -- ++ (hsize,0);
}%
end{tikzpicture}%
}%

begin{document}
ifdefinedIncludeDesiredTopSkip
%% See comments in https://tex.stackexchange.com/q/7676/4301
hbox{}kern-topskip%
vspace*{DesiredTopSkip}%
fi
First line. abcdefghij
par
Second line. abcdefghij
ShowTextGuideLines{3}
end{document}









share|improve this question






















  • But you already know that the problem is topskip: The first line is not at a distance of baselineskip (12pt) from the x but of topskip (10pt if there is nothing large in the line).
    – Ulrike Fischer
    yesterday










  • @UlrikeFischer: I thought that the kern-topskip was eliminating that as suggested at Why does vspace*{0pt} add vertical space?. But of course, having that within the ifdefined was the problem!! Thanks.
    – Peter Grill
    yesterday

















up vote
2
down vote

favorite












I have text where I want to adjust the space above the first line. I want to overlay grid lines to show where the vertical position of the text is.



The MWE below with the following line commented is the standard output. The red horizontal lines are integer multiples of baselineskip from the top.



%defIncludeDesiredTopSkip{}


enter image description here



However, if I uncomment this line (which applies the DesiredTopSkip, which is set to 0pt here), I obtain the following:



defIncludeDesiredTopSkip{}


enter image description here



Note that the baseline now is exactly on the line.



Question:



What am I missing that would explain this discrepancy in the two cases and how do I get both cases to properly display the baseline?



Note:




  • In case anyone is curious as to why I want to do this: These lines are then used to compute the parshape parameters based on where these lines intersect the particular shape.


References:




  • Why does vspace*{0pt} add vertical space?.


  • Confused with TeX terminology: height, depth, width



Code:



%defIncludeDesiredTopSkip{}
documentclass{article}
usepackage{showframe}
usepackage{tikz}

usepackage[paperwidth=7.0cm]{geometry}

newcommand*{DesiredTopSkip}{0pt}

newcommand*{ShowTextGuideLines}[1]{%
begin{tikzpicture}[remember picture, overlay]
coordinate (X) at ([
xshift=1.0in+hoffset+oddsidemargin,
yshift=-1.0in-voffset-topmargin-headheight-headsep%
]current page.north west);

node [draw=red, fill=yellow] at (X) {X};%% DEBUGGING: Ensure (X) is the correct spot.

foreach X in {1, ..., #1} {%
draw [thin, red] ([yshift=-Xbaselineskip-DesiredTopSkip]X) -- ++ (hsize,0);
}%
end{tikzpicture}%
}%

begin{document}
ifdefinedIncludeDesiredTopSkip
%% See comments in https://tex.stackexchange.com/q/7676/4301
hbox{}kern-topskip%
vspace*{DesiredTopSkip}%
fi
First line. abcdefghij
par
Second line. abcdefghij
ShowTextGuideLines{3}
end{document}









share|improve this question






















  • But you already know that the problem is topskip: The first line is not at a distance of baselineskip (12pt) from the x but of topskip (10pt if there is nothing large in the line).
    – Ulrike Fischer
    yesterday










  • @UlrikeFischer: I thought that the kern-topskip was eliminating that as suggested at Why does vspace*{0pt} add vertical space?. But of course, having that within the ifdefined was the problem!! Thanks.
    – Peter Grill
    yesterday















up vote
2
down vote

favorite









up vote
2
down vote

favorite











I have text where I want to adjust the space above the first line. I want to overlay grid lines to show where the vertical position of the text is.



The MWE below with the following line commented is the standard output. The red horizontal lines are integer multiples of baselineskip from the top.



%defIncludeDesiredTopSkip{}


enter image description here



However, if I uncomment this line (which applies the DesiredTopSkip, which is set to 0pt here), I obtain the following:



defIncludeDesiredTopSkip{}


enter image description here



Note that the baseline now is exactly on the line.



Question:



What am I missing that would explain this discrepancy in the two cases and how do I get both cases to properly display the baseline?



Note:




  • In case anyone is curious as to why I want to do this: These lines are then used to compute the parshape parameters based on where these lines intersect the particular shape.


References:




  • Why does vspace*{0pt} add vertical space?.


  • Confused with TeX terminology: height, depth, width



Code:



%defIncludeDesiredTopSkip{}
documentclass{article}
usepackage{showframe}
usepackage{tikz}

usepackage[paperwidth=7.0cm]{geometry}

newcommand*{DesiredTopSkip}{0pt}

newcommand*{ShowTextGuideLines}[1]{%
begin{tikzpicture}[remember picture, overlay]
coordinate (X) at ([
xshift=1.0in+hoffset+oddsidemargin,
yshift=-1.0in-voffset-topmargin-headheight-headsep%
]current page.north west);

node [draw=red, fill=yellow] at (X) {X};%% DEBUGGING: Ensure (X) is the correct spot.

foreach X in {1, ..., #1} {%
draw [thin, red] ([yshift=-Xbaselineskip-DesiredTopSkip]X) -- ++ (hsize,0);
}%
end{tikzpicture}%
}%

begin{document}
ifdefinedIncludeDesiredTopSkip
%% See comments in https://tex.stackexchange.com/q/7676/4301
hbox{}kern-topskip%
vspace*{DesiredTopSkip}%
fi
First line. abcdefghij
par
Second line. abcdefghij
ShowTextGuideLines{3}
end{document}









share|improve this question













I have text where I want to adjust the space above the first line. I want to overlay grid lines to show where the vertical position of the text is.



The MWE below with the following line commented is the standard output. The red horizontal lines are integer multiples of baselineskip from the top.



%defIncludeDesiredTopSkip{}


enter image description here



However, if I uncomment this line (which applies the DesiredTopSkip, which is set to 0pt here), I obtain the following:



defIncludeDesiredTopSkip{}


enter image description here



Note that the baseline now is exactly on the line.



Question:



What am I missing that would explain this discrepancy in the two cases and how do I get both cases to properly display the baseline?



Note:




  • In case anyone is curious as to why I want to do this: These lines are then used to compute the parshape parameters based on where these lines intersect the particular shape.


References:




  • Why does vspace*{0pt} add vertical space?.


  • Confused with TeX terminology: height, depth, width



Code:



%defIncludeDesiredTopSkip{}
documentclass{article}
usepackage{showframe}
usepackage{tikz}

usepackage[paperwidth=7.0cm]{geometry}

newcommand*{DesiredTopSkip}{0pt}

newcommand*{ShowTextGuideLines}[1]{%
begin{tikzpicture}[remember picture, overlay]
coordinate (X) at ([
xshift=1.0in+hoffset+oddsidemargin,
yshift=-1.0in-voffset-topmargin-headheight-headsep%
]current page.north west);

node [draw=red, fill=yellow] at (X) {X};%% DEBUGGING: Ensure (X) is the correct spot.

foreach X in {1, ..., #1} {%
draw [thin, red] ([yshift=-Xbaselineskip-DesiredTopSkip]X) -- ++ (hsize,0);
}%
end{tikzpicture}%
}%

begin{document}
ifdefinedIncludeDesiredTopSkip
%% See comments in https://tex.stackexchange.com/q/7676/4301
hbox{}kern-topskip%
vspace*{DesiredTopSkip}%
fi
First line. abcdefghij
par
Second line. abcdefghij
ShowTextGuideLines{3}
end{document}






spacing vertical-alignment boxes dimensions






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









Peter Grill

163k24432740




163k24432740












  • But you already know that the problem is topskip: The first line is not at a distance of baselineskip (12pt) from the x but of topskip (10pt if there is nothing large in the line).
    – Ulrike Fischer
    yesterday










  • @UlrikeFischer: I thought that the kern-topskip was eliminating that as suggested at Why does vspace*{0pt} add vertical space?. But of course, having that within the ifdefined was the problem!! Thanks.
    – Peter Grill
    yesterday




















  • But you already know that the problem is topskip: The first line is not at a distance of baselineskip (12pt) from the x but of topskip (10pt if there is nothing large in the line).
    – Ulrike Fischer
    yesterday










  • @UlrikeFischer: I thought that the kern-topskip was eliminating that as suggested at Why does vspace*{0pt} add vertical space?. But of course, having that within the ifdefined was the problem!! Thanks.
    – Peter Grill
    yesterday


















But you already know that the problem is topskip: The first line is not at a distance of baselineskip (12pt) from the x but of topskip (10pt if there is nothing large in the line).
– Ulrike Fischer
yesterday




But you already know that the problem is topskip: The first line is not at a distance of baselineskip (12pt) from the x but of topskip (10pt if there is nothing large in the line).
– Ulrike Fischer
yesterday












@UlrikeFischer: I thought that the kern-topskip was eliminating that as suggested at Why does vspace*{0pt} add vertical space?. But of course, having that within the ifdefined was the problem!! Thanks.
– Peter Grill
yesterday






@UlrikeFischer: I thought that the kern-topskip was eliminating that as suggested at Why does vspace*{0pt} add vertical space?. But of course, having that within the ifdefined was the problem!! Thanks.
– Peter Grill
yesterday












1 Answer
1






active

oldest

votes

















up vote
2
down vote













This answer does not really address the question you ask explicitly, but I think it does accomplish what you are trying to do.



The lineno package generates line numbers and places them in the margin.
I'm (ab)using this package by telling it to print red horizontal rules instead of numbers, which has the desired effect.



documentclass{article}

usepackage{lineno} %% <- package for numbering lines
%linenumbers %% <- turns on line "numbering" globally

usepackage{xcolor} %% <- colour support

newcommand*{redline}{color{red}rule[-.4pt]{textwidth}{.4pt}}
%% ^^ the optional argument puts the rule just /below/ the baseline.
%% ^^ to centre it on the baseline, change it to -.2pt.
%% ^^ remove the optional argument to place it on top of the baseline
setmakelinenumbersredline %% <- draw a horizontal rule instead of numbers

usepackage{blindtext} %% <- for blindtext

begin{document}

blindtext[1]

linenumbers

blindtext[1]

nolinenumbers

blindtext[1]

end{document}


output



Note that instead of linenumbers ... nolinenumbers you can also use begin{linenumbers}...end{linenumbers} if you prefer this syntax.






share|improve this answer





















  • Nice hack. I need the lines to be drawn in tikz so that I can compute intersections.
    – Peter Grill
    yesterday










  • Ah, I see. Do you plan to use this to have your text flow around an image? That's a pretty neat idea.
    – Circumscribe
    yesterday










  • At the moment, I am using this to determine the parshape parameters so that the text takes on a particular shape -- based on the output display. But, in the future I could use this to adjust the parshape to flow around an image as well.
    – Peter Grill
    yesterday










  • My answer probably won't be helpful then. To use Tikz you can of course instead define newcommand*{redline}{tikz[baseline] draw[thin,red] (0,0) -- (textwidth,0);}, but I suspect that you'll want to compute these intersections and call parshape before rendering any actual text.
    – Circumscribe
    yesterday











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%2f461069%2fdrawing-grid-lines-to-show-vertical-position-of-text%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote













This answer does not really address the question you ask explicitly, but I think it does accomplish what you are trying to do.



The lineno package generates line numbers and places them in the margin.
I'm (ab)using this package by telling it to print red horizontal rules instead of numbers, which has the desired effect.



documentclass{article}

usepackage{lineno} %% <- package for numbering lines
%linenumbers %% <- turns on line "numbering" globally

usepackage{xcolor} %% <- colour support

newcommand*{redline}{color{red}rule[-.4pt]{textwidth}{.4pt}}
%% ^^ the optional argument puts the rule just /below/ the baseline.
%% ^^ to centre it on the baseline, change it to -.2pt.
%% ^^ remove the optional argument to place it on top of the baseline
setmakelinenumbersredline %% <- draw a horizontal rule instead of numbers

usepackage{blindtext} %% <- for blindtext

begin{document}

blindtext[1]

linenumbers

blindtext[1]

nolinenumbers

blindtext[1]

end{document}


output



Note that instead of linenumbers ... nolinenumbers you can also use begin{linenumbers}...end{linenumbers} if you prefer this syntax.






share|improve this answer





















  • Nice hack. I need the lines to be drawn in tikz so that I can compute intersections.
    – Peter Grill
    yesterday










  • Ah, I see. Do you plan to use this to have your text flow around an image? That's a pretty neat idea.
    – Circumscribe
    yesterday










  • At the moment, I am using this to determine the parshape parameters so that the text takes on a particular shape -- based on the output display. But, in the future I could use this to adjust the parshape to flow around an image as well.
    – Peter Grill
    yesterday










  • My answer probably won't be helpful then. To use Tikz you can of course instead define newcommand*{redline}{tikz[baseline] draw[thin,red] (0,0) -- (textwidth,0);}, but I suspect that you'll want to compute these intersections and call parshape before rendering any actual text.
    – Circumscribe
    yesterday















up vote
2
down vote













This answer does not really address the question you ask explicitly, but I think it does accomplish what you are trying to do.



The lineno package generates line numbers and places them in the margin.
I'm (ab)using this package by telling it to print red horizontal rules instead of numbers, which has the desired effect.



documentclass{article}

usepackage{lineno} %% <- package for numbering lines
%linenumbers %% <- turns on line "numbering" globally

usepackage{xcolor} %% <- colour support

newcommand*{redline}{color{red}rule[-.4pt]{textwidth}{.4pt}}
%% ^^ the optional argument puts the rule just /below/ the baseline.
%% ^^ to centre it on the baseline, change it to -.2pt.
%% ^^ remove the optional argument to place it on top of the baseline
setmakelinenumbersredline %% <- draw a horizontal rule instead of numbers

usepackage{blindtext} %% <- for blindtext

begin{document}

blindtext[1]

linenumbers

blindtext[1]

nolinenumbers

blindtext[1]

end{document}


output



Note that instead of linenumbers ... nolinenumbers you can also use begin{linenumbers}...end{linenumbers} if you prefer this syntax.






share|improve this answer





















  • Nice hack. I need the lines to be drawn in tikz so that I can compute intersections.
    – Peter Grill
    yesterday










  • Ah, I see. Do you plan to use this to have your text flow around an image? That's a pretty neat idea.
    – Circumscribe
    yesterday










  • At the moment, I am using this to determine the parshape parameters so that the text takes on a particular shape -- based on the output display. But, in the future I could use this to adjust the parshape to flow around an image as well.
    – Peter Grill
    yesterday










  • My answer probably won't be helpful then. To use Tikz you can of course instead define newcommand*{redline}{tikz[baseline] draw[thin,red] (0,0) -- (textwidth,0);}, but I suspect that you'll want to compute these intersections and call parshape before rendering any actual text.
    – Circumscribe
    yesterday













up vote
2
down vote










up vote
2
down vote









This answer does not really address the question you ask explicitly, but I think it does accomplish what you are trying to do.



The lineno package generates line numbers and places them in the margin.
I'm (ab)using this package by telling it to print red horizontal rules instead of numbers, which has the desired effect.



documentclass{article}

usepackage{lineno} %% <- package for numbering lines
%linenumbers %% <- turns on line "numbering" globally

usepackage{xcolor} %% <- colour support

newcommand*{redline}{color{red}rule[-.4pt]{textwidth}{.4pt}}
%% ^^ the optional argument puts the rule just /below/ the baseline.
%% ^^ to centre it on the baseline, change it to -.2pt.
%% ^^ remove the optional argument to place it on top of the baseline
setmakelinenumbersredline %% <- draw a horizontal rule instead of numbers

usepackage{blindtext} %% <- for blindtext

begin{document}

blindtext[1]

linenumbers

blindtext[1]

nolinenumbers

blindtext[1]

end{document}


output



Note that instead of linenumbers ... nolinenumbers you can also use begin{linenumbers}...end{linenumbers} if you prefer this syntax.






share|improve this answer












This answer does not really address the question you ask explicitly, but I think it does accomplish what you are trying to do.



The lineno package generates line numbers and places them in the margin.
I'm (ab)using this package by telling it to print red horizontal rules instead of numbers, which has the desired effect.



documentclass{article}

usepackage{lineno} %% <- package for numbering lines
%linenumbers %% <- turns on line "numbering" globally

usepackage{xcolor} %% <- colour support

newcommand*{redline}{color{red}rule[-.4pt]{textwidth}{.4pt}}
%% ^^ the optional argument puts the rule just /below/ the baseline.
%% ^^ to centre it on the baseline, change it to -.2pt.
%% ^^ remove the optional argument to place it on top of the baseline
setmakelinenumbersredline %% <- draw a horizontal rule instead of numbers

usepackage{blindtext} %% <- for blindtext

begin{document}

blindtext[1]

linenumbers

blindtext[1]

nolinenumbers

blindtext[1]

end{document}


output



Note that instead of linenumbers ... nolinenumbers you can also use begin{linenumbers}...end{linenumbers} if you prefer this syntax.







share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









Circumscribe

2,6621324




2,6621324












  • Nice hack. I need the lines to be drawn in tikz so that I can compute intersections.
    – Peter Grill
    yesterday










  • Ah, I see. Do you plan to use this to have your text flow around an image? That's a pretty neat idea.
    – Circumscribe
    yesterday










  • At the moment, I am using this to determine the parshape parameters so that the text takes on a particular shape -- based on the output display. But, in the future I could use this to adjust the parshape to flow around an image as well.
    – Peter Grill
    yesterday










  • My answer probably won't be helpful then. To use Tikz you can of course instead define newcommand*{redline}{tikz[baseline] draw[thin,red] (0,0) -- (textwidth,0);}, but I suspect that you'll want to compute these intersections and call parshape before rendering any actual text.
    – Circumscribe
    yesterday


















  • Nice hack. I need the lines to be drawn in tikz so that I can compute intersections.
    – Peter Grill
    yesterday










  • Ah, I see. Do you plan to use this to have your text flow around an image? That's a pretty neat idea.
    – Circumscribe
    yesterday










  • At the moment, I am using this to determine the parshape parameters so that the text takes on a particular shape -- based on the output display. But, in the future I could use this to adjust the parshape to flow around an image as well.
    – Peter Grill
    yesterday










  • My answer probably won't be helpful then. To use Tikz you can of course instead define newcommand*{redline}{tikz[baseline] draw[thin,red] (0,0) -- (textwidth,0);}, but I suspect that you'll want to compute these intersections and call parshape before rendering any actual text.
    – Circumscribe
    yesterday
















Nice hack. I need the lines to be drawn in tikz so that I can compute intersections.
– Peter Grill
yesterday




Nice hack. I need the lines to be drawn in tikz so that I can compute intersections.
– Peter Grill
yesterday












Ah, I see. Do you plan to use this to have your text flow around an image? That's a pretty neat idea.
– Circumscribe
yesterday




Ah, I see. Do you plan to use this to have your text flow around an image? That's a pretty neat idea.
– Circumscribe
yesterday












At the moment, I am using this to determine the parshape parameters so that the text takes on a particular shape -- based on the output display. But, in the future I could use this to adjust the parshape to flow around an image as well.
– Peter Grill
yesterday




At the moment, I am using this to determine the parshape parameters so that the text takes on a particular shape -- based on the output display. But, in the future I could use this to adjust the parshape to flow around an image as well.
– Peter Grill
yesterday












My answer probably won't be helpful then. To use Tikz you can of course instead define newcommand*{redline}{tikz[baseline] draw[thin,red] (0,0) -- (textwidth,0);}, but I suspect that you'll want to compute these intersections and call parshape before rendering any actual text.
– Circumscribe
yesterday




My answer probably won't be helpful then. To use Tikz you can of course instead define newcommand*{redline}{tikz[baseline] draw[thin,red] (0,0) -- (textwidth,0);}, but I suspect that you'll want to compute these intersections and call parshape before rendering any actual text.
– Circumscribe
yesterday


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461069%2fdrawing-grid-lines-to-show-vertical-position-of-text%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

Entries order in /etc/network/interfaces

新発田市

Grub takes very long (several minutes) to open Menu (in Multi-Boot-System)