can glue be colored?

The name of the pictureThe name of the pictureThe name of the pictureClash 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?










share|improve this question



















  • 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 vspace which is easy to implement (using TikZ), but would need at least 2 runs to get it right.
    – Skillmon
    47 mins ago














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?










share|improve this question



















  • 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 vspace which is easy to implement (using TikZ), but would need at least 2 runs to get it right.
    – Skillmon
    47 mins ago












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?










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 for vspace which is easy to implement (using TikZ), but would need at least 2 runs to get it right.
    – Skillmon
    47 mins ago












  • 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 vspace which 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










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


enter image description here






share|improve this answer





























    up vote
    1
    down vote













    documentclassarticle

    usepackagecolor

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


    enter image description here



    Variant



    documentclassarticle

    usepackagecolor

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


    enter image description here






    share|improve this answer






















      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: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      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%2f450820%2fcan-glue-be-colored%23new-answer', 'question_page');

      );

      Post as a guest






























      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


      enter image description here






      share|improve this answer


























        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


        enter image description here






        share|improve this answer
























          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


          enter image description here






          share|improve this answer














          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


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 13 mins ago

























          answered 51 mins ago









          Skillmon

          17.6k11535




          17.6k11535




















              up vote
              1
              down vote













              documentclassarticle

              usepackagecolor

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


              enter image description here



              Variant



              documentclassarticle

              usepackagecolor

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


              enter image description here






              share|improve this answer


























                up vote
                1
                down vote













                documentclassarticle

                usepackagecolor

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


                enter image description here



                Variant



                documentclassarticle

                usepackagecolor

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


                enter image description here






                share|improve this answer
























                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  documentclassarticle

                  usepackagecolor

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


                  enter image description here



                  Variant



                  documentclassarticle

                  usepackagecolor

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


                  enter image description here






                  share|improve this answer














                  documentclassarticle

                  usepackagecolor

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


                  enter image description here



                  Variant



                  documentclassarticle

                  usepackagecolor

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


                  enter image description here







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 4 mins ago

























                  answered 10 mins ago









                  jfbu

                  41.5k61134




                  41.5k61134



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      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













































































                      Comments

                      Popular posts from this blog

                      How to decode/decipher Mozilla Firefox proprietary .jsonlz4 format? (sessionstore-backups/recovery.jsonlz4)

                      White Anglo-Saxon Protestant

                      How to be valuable when automation & IT are stealing my job (and maybe my whole career)? [closed]