can glue be colored?

Clash Royale CLAN TAG#URR8PPP
up vote
5
down vote
favorite
When I'm fine-tuning the design of my documents in LaTeX/XeLaTeX, it's sometimes helpful to use color to highlight the location and size of my fixed spacing. For example, I sometimes temporarily replace code like hspace2pt with the code textcolorredrule2pt2pt} so I can very clearly see the 2pt space and, for example, make sure there are not any unintended spaces or extra spaces appearing on the left or right of my definite 2pt space.
But I have not been able to find a similar way in LaTeX/XeLaTeX of colorfully highlighting the stretchable glue that I use in my documents.
For example, textcolorredhspace6pt plus 2pt minus 1pt doesn't work.
Also, textcolorredrule6pt plus 2pt minus 1pt2pt doesn't work.
How can I apply color to stretchable glue using TeX/LaTeX/XeLaTeX so it is easy to see it when I am fine-tuning my documents?
Is there maybe a way to color the background (i.e., the paper) so that stretchable glue will appear to be colored compared to the text before and after it?
Is there maybe a programmatic way of detecting the value of the stretchable glue as the document is being compiled and automatically replacing the stretchable glue with a rule set to the same width as the stretchable glue?
color glue
add a comment |Â
up vote
5
down vote
favorite
When I'm fine-tuning the design of my documents in LaTeX/XeLaTeX, it's sometimes helpful to use color to highlight the location and size of my fixed spacing. For example, I sometimes temporarily replace code like hspace2pt with the code textcolorredrule2pt2pt} so I can very clearly see the 2pt space and, for example, make sure there are not any unintended spaces or extra spaces appearing on the left or right of my definite 2pt space.
But I have not been able to find a similar way in LaTeX/XeLaTeX of colorfully highlighting the stretchable glue that I use in my documents.
For example, textcolorredhspace6pt plus 2pt minus 1pt doesn't work.
Also, textcolorredrule6pt plus 2pt minus 1pt2pt doesn't work.
How can I apply color to stretchable glue using TeX/LaTeX/XeLaTeX so it is easy to see it when I am fine-tuning my documents?
Is there maybe a way to color the background (i.e., the paper) so that stretchable glue will appear to be colored compared to the text before and after it?
Is there maybe a programmatic way of detecting the value of the stretchable glue as the document is being compiled and automatically replacing the stretchable glue with a rule set to the same width as the stretchable glue?
color glue
3
I think this has been done in LuaTeX. I highly recommend this blog post.
â Ruixi Zhang
5 hours ago
Good article. My projects are almost always in XeLaTeX, so I am not sure I can implement that LuaTeX solution. I will investigate it further. Thanks. EDIT: That LuaTeX solution definitely requires LuaTeX and can't be done in XeLaTeX. I'm hopeful for a TeX/LaTeX solution.
â Tim Stewart
5 hours ago
I might have an idea forvspacewhich is easy to implement (using TikZ), but would need at least 2 runs to get it right.
â Skillmon
47 mins ago
add a comment |Â
up vote
5
down vote
favorite
up vote
5
down vote
favorite
When I'm fine-tuning the design of my documents in LaTeX/XeLaTeX, it's sometimes helpful to use color to highlight the location and size of my fixed spacing. For example, I sometimes temporarily replace code like hspace2pt with the code textcolorredrule2pt2pt} so I can very clearly see the 2pt space and, for example, make sure there are not any unintended spaces or extra spaces appearing on the left or right of my definite 2pt space.
But I have not been able to find a similar way in LaTeX/XeLaTeX of colorfully highlighting the stretchable glue that I use in my documents.
For example, textcolorredhspace6pt plus 2pt minus 1pt doesn't work.
Also, textcolorredrule6pt plus 2pt minus 1pt2pt doesn't work.
How can I apply color to stretchable glue using TeX/LaTeX/XeLaTeX so it is easy to see it when I am fine-tuning my documents?
Is there maybe a way to color the background (i.e., the paper) so that stretchable glue will appear to be colored compared to the text before and after it?
Is there maybe a programmatic way of detecting the value of the stretchable glue as the document is being compiled and automatically replacing the stretchable glue with a rule set to the same width as the stretchable glue?
color glue
When I'm fine-tuning the design of my documents in LaTeX/XeLaTeX, it's sometimes helpful to use color to highlight the location and size of my fixed spacing. For example, I sometimes temporarily replace code like hspace2pt with the code textcolorredrule2pt2pt} so I can very clearly see the 2pt space and, for example, make sure there are not any unintended spaces or extra spaces appearing on the left or right of my definite 2pt space.
But I have not been able to find a similar way in LaTeX/XeLaTeX of colorfully highlighting the stretchable glue that I use in my documents.
For example, textcolorredhspace6pt plus 2pt minus 1pt doesn't work.
Also, textcolorredrule6pt plus 2pt minus 1pt2pt doesn't work.
How can I apply color to stretchable glue using TeX/LaTeX/XeLaTeX so it is easy to see it when I am fine-tuning my documents?
Is there maybe a way to color the background (i.e., the paper) so that stretchable glue will appear to be colored compared to the text before and after it?
Is there maybe a programmatic way of detecting the value of the stretchable glue as the document is being compiled and automatically replacing the stretchable glue with a rule set to the same width as the stretchable glue?
color glue
color glue
edited 3 hours ago
asked 6 hours ago
Tim Stewart
1116
1116
3
I think this has been done in LuaTeX. I highly recommend this blog post.
â Ruixi Zhang
5 hours ago
Good article. My projects are almost always in XeLaTeX, so I am not sure I can implement that LuaTeX solution. I will investigate it further. Thanks. EDIT: That LuaTeX solution definitely requires LuaTeX and can't be done in XeLaTeX. I'm hopeful for a TeX/LaTeX solution.
â Tim Stewart
5 hours ago
I might have an idea forvspacewhich is easy to implement (using TikZ), but would need at least 2 runs to get it right.
â Skillmon
47 mins ago
add a comment |Â
3
I think this has been done in LuaTeX. I highly recommend this blog post.
â Ruixi Zhang
5 hours ago
Good article. My projects are almost always in XeLaTeX, so I am not sure I can implement that LuaTeX solution. I will investigate it further. Thanks. EDIT: That LuaTeX solution definitely requires LuaTeX and can't be done in XeLaTeX. I'm hopeful for a TeX/LaTeX solution.
â Tim Stewart
5 hours ago
I might have an idea forvspacewhich is easy to implement (using TikZ), but would need at least 2 runs to get it right.
â Skillmon
47 mins ago
3
3
I think this has been done in LuaTeX. I highly recommend this blog post.
â Ruixi Zhang
5 hours ago
I think this has been done in LuaTeX. I highly recommend this blog post.
â Ruixi Zhang
5 hours ago
Good article. My projects are almost always in XeLaTeX, so I am not sure I can implement that LuaTeX solution. I will investigate it further. Thanks. EDIT: That LuaTeX solution definitely requires LuaTeX and can't be done in XeLaTeX. I'm hopeful for a TeX/LaTeX solution.
â Tim Stewart
5 hours ago
Good article. My projects are almost always in XeLaTeX, so I am not sure I can implement that LuaTeX solution. I will investigate it further. Thanks. EDIT: That LuaTeX solution definitely requires LuaTeX and can't be done in XeLaTeX. I'm hopeful for a TeX/LaTeX solution.
â Tim Stewart
5 hours ago
I might have an idea for
vspace which is easy to implement (using TikZ), but would need at least 2 runs to get it right.â Skillmon
47 mins ago
I might have an idea for
vspace which is easy to implement (using TikZ), but would need at least 2 runs to get it right.â Skillmon
47 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
A solution working for hspace (didn't look into vspace yet, but it won't work the same way).
EDIT also a solution for vspace but it will not always behave like a vspace.
documentclassarticle
usepackagexcolor
usepackage[normalem]ulem
usepackagetikz
makeatletter
newcommand*hlhspace@ifstarhlhspace@starhlhspace@nostar
newcommand*hlhspace@nostar[1]hlhspace@outhspace#1
newcommand*hlhspace@star[1]hlhspace@outhspace*#1
newcommand*hlhspace@out[1]
%
begingroup
colorred%
bgroup
markoverwithrule[-.3ex]0.2ex2ex%
ULon#1%
endgroup
newcommand*hlvspace@ifstarhlvspace@outhlvspace@out
newcommand*hlvspace@out[1]
%
tikz[remember picture, overlay, baseline=(Begin.base)]
%
node[anchor=base, inner sep=0pt, outer sep=0pt] (Begin) strut;
%
vskip #1relax
tikz[remember picture, overlay, baseline=(End.base)]
%
node[anchor=base, inner sep=0pt, outer sep=0pt] (End) strut;
draw[red,line width=2ex] (Begin.base) -- (End.base);
makeatother
begindocument
hbox to textwidthThis text hlhspace5pt plus 5pt is justified.
Text
hlvspace*5pt plus 1fill
More text.
noindent
more text.
enddocument

add a comment |Â
up vote
1
down vote
documentclassarticle
usepackagecolor
begindocument
noindent This text colorredleadersvrulehfill is
justified.newline And continues here.
enddocument

Variant
documentclassarticle
usepackagecolor
begindocument
noindent This text colorredstrutleadersvrulehfill is
justified.newline And continues here.
enddocument

add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
A solution working for hspace (didn't look into vspace yet, but it won't work the same way).
EDIT also a solution for vspace but it will not always behave like a vspace.
documentclassarticle
usepackagexcolor
usepackage[normalem]ulem
usepackagetikz
makeatletter
newcommand*hlhspace@ifstarhlhspace@starhlhspace@nostar
newcommand*hlhspace@nostar[1]hlhspace@outhspace#1
newcommand*hlhspace@star[1]hlhspace@outhspace*#1
newcommand*hlhspace@out[1]
%
begingroup
colorred%
bgroup
markoverwithrule[-.3ex]0.2ex2ex%
ULon#1%
endgroup
newcommand*hlvspace@ifstarhlvspace@outhlvspace@out
newcommand*hlvspace@out[1]
%
tikz[remember picture, overlay, baseline=(Begin.base)]
%
node[anchor=base, inner sep=0pt, outer sep=0pt] (Begin) strut;
%
vskip #1relax
tikz[remember picture, overlay, baseline=(End.base)]
%
node[anchor=base, inner sep=0pt, outer sep=0pt] (End) strut;
draw[red,line width=2ex] (Begin.base) -- (End.base);
makeatother
begindocument
hbox to textwidthThis text hlhspace5pt plus 5pt is justified.
Text
hlvspace*5pt plus 1fill
More text.
noindent
more text.
enddocument

add a comment |Â
up vote
3
down vote
A solution working for hspace (didn't look into vspace yet, but it won't work the same way).
EDIT also a solution for vspace but it will not always behave like a vspace.
documentclassarticle
usepackagexcolor
usepackage[normalem]ulem
usepackagetikz
makeatletter
newcommand*hlhspace@ifstarhlhspace@starhlhspace@nostar
newcommand*hlhspace@nostar[1]hlhspace@outhspace#1
newcommand*hlhspace@star[1]hlhspace@outhspace*#1
newcommand*hlhspace@out[1]
%
begingroup
colorred%
bgroup
markoverwithrule[-.3ex]0.2ex2ex%
ULon#1%
endgroup
newcommand*hlvspace@ifstarhlvspace@outhlvspace@out
newcommand*hlvspace@out[1]
%
tikz[remember picture, overlay, baseline=(Begin.base)]
%
node[anchor=base, inner sep=0pt, outer sep=0pt] (Begin) strut;
%
vskip #1relax
tikz[remember picture, overlay, baseline=(End.base)]
%
node[anchor=base, inner sep=0pt, outer sep=0pt] (End) strut;
draw[red,line width=2ex] (Begin.base) -- (End.base);
makeatother
begindocument
hbox to textwidthThis text hlhspace5pt plus 5pt is justified.
Text
hlvspace*5pt plus 1fill
More text.
noindent
more text.
enddocument

add a comment |Â
up vote
3
down vote
up vote
3
down vote
A solution working for hspace (didn't look into vspace yet, but it won't work the same way).
EDIT also a solution for vspace but it will not always behave like a vspace.
documentclassarticle
usepackagexcolor
usepackage[normalem]ulem
usepackagetikz
makeatletter
newcommand*hlhspace@ifstarhlhspace@starhlhspace@nostar
newcommand*hlhspace@nostar[1]hlhspace@outhspace#1
newcommand*hlhspace@star[1]hlhspace@outhspace*#1
newcommand*hlhspace@out[1]
%
begingroup
colorred%
bgroup
markoverwithrule[-.3ex]0.2ex2ex%
ULon#1%
endgroup
newcommand*hlvspace@ifstarhlvspace@outhlvspace@out
newcommand*hlvspace@out[1]
%
tikz[remember picture, overlay, baseline=(Begin.base)]
%
node[anchor=base, inner sep=0pt, outer sep=0pt] (Begin) strut;
%
vskip #1relax
tikz[remember picture, overlay, baseline=(End.base)]
%
node[anchor=base, inner sep=0pt, outer sep=0pt] (End) strut;
draw[red,line width=2ex] (Begin.base) -- (End.base);
makeatother
begindocument
hbox to textwidthThis text hlhspace5pt plus 5pt is justified.
Text
hlvspace*5pt plus 1fill
More text.
noindent
more text.
enddocument

A solution working for hspace (didn't look into vspace yet, but it won't work the same way).
EDIT also a solution for vspace but it will not always behave like a vspace.
documentclassarticle
usepackagexcolor
usepackage[normalem]ulem
usepackagetikz
makeatletter
newcommand*hlhspace@ifstarhlhspace@starhlhspace@nostar
newcommand*hlhspace@nostar[1]hlhspace@outhspace#1
newcommand*hlhspace@star[1]hlhspace@outhspace*#1
newcommand*hlhspace@out[1]
%
begingroup
colorred%
bgroup
markoverwithrule[-.3ex]0.2ex2ex%
ULon#1%
endgroup
newcommand*hlvspace@ifstarhlvspace@outhlvspace@out
newcommand*hlvspace@out[1]
%
tikz[remember picture, overlay, baseline=(Begin.base)]
%
node[anchor=base, inner sep=0pt, outer sep=0pt] (Begin) strut;
%
vskip #1relax
tikz[remember picture, overlay, baseline=(End.base)]
%
node[anchor=base, inner sep=0pt, outer sep=0pt] (End) strut;
draw[red,line width=2ex] (Begin.base) -- (End.base);
makeatother
begindocument
hbox to textwidthThis text hlhspace5pt plus 5pt is justified.
Text
hlvspace*5pt plus 1fill
More text.
noindent
more text.
enddocument

edited 13 mins ago
answered 51 mins ago
Skillmon
17.6k11535
17.6k11535
add a comment |Â
add a comment |Â
up vote
1
down vote
documentclassarticle
usepackagecolor
begindocument
noindent This text colorredleadersvrulehfill is
justified.newline And continues here.
enddocument

Variant
documentclassarticle
usepackagecolor
begindocument
noindent This text colorredstrutleadersvrulehfill is
justified.newline And continues here.
enddocument

add a comment |Â
up vote
1
down vote
documentclassarticle
usepackagecolor
begindocument
noindent This text colorredleadersvrulehfill is
justified.newline And continues here.
enddocument

Variant
documentclassarticle
usepackagecolor
begindocument
noindent This text colorredstrutleadersvrulehfill is
justified.newline And continues here.
enddocument

add a comment |Â
up vote
1
down vote
up vote
1
down vote
documentclassarticle
usepackagecolor
begindocument
noindent This text colorredleadersvrulehfill is
justified.newline And continues here.
enddocument

Variant
documentclassarticle
usepackagecolor
begindocument
noindent This text colorredstrutleadersvrulehfill is
justified.newline And continues here.
enddocument

documentclassarticle
usepackagecolor
begindocument
noindent This text colorredleadersvrulehfill is
justified.newline And continues here.
enddocument

Variant
documentclassarticle
usepackagecolor
begindocument
noindent This text colorredstrutleadersvrulehfill is
justified.newline And continues here.
enddocument

edited 4 mins ago
answered 10 mins ago
jfbu
41.5k61134
41.5k61134
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f450820%2fcan-glue-be-colored%23new-answer', 'question_page');
);
Post as a guest
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
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
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

3
I think this has been done in LuaTeX. I highly recommend this blog post.
â Ruixi Zhang
5 hours ago
Good article. My projects are almost always in XeLaTeX, so I am not sure I can implement that LuaTeX solution. I will investigate it further. Thanks. EDIT: That LuaTeX solution definitely requires LuaTeX and can't be done in XeLaTeX. I'm hopeful for a TeX/LaTeX solution.
â Tim Stewart
5 hours ago
I might have an idea for
vspacewhich is easy to implement (using TikZ), but would need at least 2 runs to get it right.â Skillmon
47 mins ago