Draw a dash-dotted line Unicorn Meta Zoo #1: Why another podcast? Announcing...

Does Mathematica have an implementation of the Poisson Binomial Distribution?

Trumpet valves, lengths, and pitch

Raising a bilingual kid. When should we introduce the majority language?

How do I check if a string is entirely made of the same substring?

How to get even lighting when using flash for group photos near wall?

My bank got bought out, am I now going to have to start filing tax returns in a different state?

What was Apollo 13's "Little Jolt" after MECO?

How to translate "red flag" into Spanish?

std::is_constructible on incomplete types

Align column where each cell has two decimals with siunitx

Implementing 3DES algorithm in Java: is my code secure?

Are these square matrices always diagonalisable?

How would I use different systems of magic when they are capable of the same effects?

What is /etc/mtab in Linux?

Is a 5 watt UHF/VHF handheld considered QRP?

Second order approximation of the loss function (Deep learning book, 7.33)

"My boss was furious with me and I have been fired" vs. "My boss was furious with me and I was fired"

Error: Syntax error. Missing ')' for CASE Statement

Check if a string is entirely made of the same substring

How to avoid introduction cliches

What is the least dense liquid under normal conditions?

What is the term for a person whose job is to place products on shelves in stores?

Why does the Cisco show run command not show the full version, while the show version command does?

I preordered a game on my Xbox while on the home screen of my friend's account. Which of us owns the game?



Draw a dash-dotted line



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraWant to fill line with repeating stringEquivalent Leaders constructionHow to draw dashes and pipe lines in latex and add text below themCreating a rectangle area plot with pgfplots/tikzintermittent/broken line in flow chartDotted lines in TikZ with round dotsScale dash pattern with line widthURL with dotted/customized underline AND line breakingDraw dotted line with circled dots and automatic spacingHow can I draw a curved-arrowed dash line (with expressions above) between two pictures?How to draw dashes and pipe lines in latex and add text below themDraw transmission line circuitsDotted filled line with arrow head in tikzTikz custom dotted patternDraw shading rectangle












15















How can I produce a dash-dotted line .-.-.-.-? I tried to find something in the tikz manual, but didn't find anything.










share|improve this question

























  • please see tex.stackexchange.com/questions/38423/… and tex.stackexchange.com/questions/253291/…

    – touhami
    Sep 4 '16 at 19:53
















15















How can I produce a dash-dotted line .-.-.-.-? I tried to find something in the tikz manual, but didn't find anything.










share|improve this question

























  • please see tex.stackexchange.com/questions/38423/… and tex.stackexchange.com/questions/253291/…

    – touhami
    Sep 4 '16 at 19:53














15












15








15


5






How can I produce a dash-dotted line .-.-.-.-? I tried to find something in the tikz manual, but didn't find anything.










share|improve this question
















How can I produce a dash-dotted line .-.-.-.-? I tried to find something in the tikz manual, but didn't find anything.







tikz-pgf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 29 mins ago







Ben

















asked Sep 4 '16 at 19:49









BenBen

9751520




9751520













  • please see tex.stackexchange.com/questions/38423/… and tex.stackexchange.com/questions/253291/…

    – touhami
    Sep 4 '16 at 19:53



















  • please see tex.stackexchange.com/questions/38423/… and tex.stackexchange.com/questions/253291/…

    – touhami
    Sep 4 '16 at 19:53

















please see tex.stackexchange.com/questions/38423/… and tex.stackexchange.com/questions/253291/…

– touhami
Sep 4 '16 at 19:53





please see tex.stackexchange.com/questions/38423/… and tex.stackexchange.com/questions/253291/…

– touhami
Sep 4 '16 at 19:53










3 Answers
3






active

oldest

votes


















36














The various pre-defined dash patterns are documented in section 15.3.2 Graphic Parameters: Dash Pattern of the manual (for version 3.0.1.a dated 29 August 2015). They are dotted, dashed, dash dot and dash dot dot. Each of these have denser and looser variants, e.g. densely dashed and loosely dotted. Equivalently for the others.



In addition you can specify a custom pattern using e.g. dash pattern={on 4pt off 1pt on 2pt off 3pt}, which I guess is self explanatory.



documentclass{article}
usepackage{tikz}

begin{document}
begin{tikzpicture}
draw [thick,dash dot] (0,1) -- (5,1);
draw [thick,dash pattern={on 7pt off 2pt on 1pt off 3pt}] (0,0) -- (5,0);
end{tikzpicture}

end{document}


enter image description here



Addendum



If you want to put a line like this in the text, and aligned better to the surrounding text, then you can add the baseline=<length> option to the tikzpicture. By default the bottom end of the tikzpicture is placed on the baseline of the surrounding text. If you add baseline=10pt then the tikzpicture will be placed so that y=10pt in its internal coordinate system is on the baseline of the surrounding text.



Here is an example. tikz is a short form of the tikzpicture environment, intended for simple pictures placed in the text.



documentclass{article}
usepackage{tikz}

begin{document}
Lorem ipsum tikzdraw [thick,dash dot] (0,0) -- (3,0); dolor sit amet

Lorem ipsum tikz[baseline=-0.5ex]draw [thick,dash dot] (0,0) -- (3,0); dolor sit amet
end{document}


enter image description here






share|improve this answer


























  • (x1, y1) and (x2, y2) seem to be coordinates. Is it right, that the coordinate with the lower x part is set to be wherever the environment ends? My tests tell so. Than how can I set the line in the middle line high, like appearing like this: before --- after

    – Ben
    Sep 4 '16 at 20:21











  • *wherever the environment starts

    – Ben
    Sep 4 '16 at 20:27






  • 1





    @Ben I'm not entirely sure what you mean, but I think you're after the baseline key, see the addition to my answer.

    – Torbjørn T.
    Sep 4 '16 at 20:32











  • I am sorry, but how can it be written if the length is needed to be a fraction of textwidth or 2cm for example?

    – Diaa
    Sep 4 '16 at 20:40






  • 2





    @DiaaAbidou As mentioned above, the default unit vectors are 1cm, so a line from (0,0) to (2,0) would be 2cm. That said, you can also use explicit units, so draw (0,0) -- (2cm,0); works. And TeX lengths work as well, so you can say e.g. draw (0,0) -- (0.1linewidth,0);

    – Torbjørn T.
    Sep 4 '16 at 20:52





















8














Here is a version using leaders. While all the parameters can be changed, the main ones are dashdotline{<length>} to draw the line, with these configurations: dashfrac{<percent of repetition used by dash>}; replength=<repetition-length>relax.



documentclass[10pt]{article}
newlengthreplength
newcommandrepfrac{.40}% PERCENT OF REPETITION USED BY DASH
newcommanddashfrac[1]{renewcommandrepfrac{#1}}% MACRO TO ALTER repfrac
setlengthreplength{8.5pt}% REPITITION LENGTH
newcommandrulewidth{.6pt}% DASH WIDTH
defdashht{.5dimexprhtstrutbox-dpstrutboxrelax}
newcommandtdashfill[1][repfrac]{cleadershbox to replength{%
smash{rule[dashht]{repfracreplength}{rulewidth}%
kern.5dimexprreplength-repfracreplength-2.5ptrelax%
raisebox{dimexprdashht-.3pt}{.}}}hfill}
newcommanddashdotline[1]{%
makebox[#1][l]{tdashfillhfil}}
begin{document}
xdashdotline{2in}ypar
replength 17.5pt
xdashdotline{1in}ypar
dashfrac{.66}
xdashdotline{1in}y
end{document}


enter image description here






share|improve this answer































    0














    Yet another solution with leaders, not perfect but as simple as possible:



    xleadershbox to 1em{$- cdot$}hfill $-$


    If you will use this often, define some macro as dashdotted,
    If you want a specific length instead of filling the line, simply enclose it in a makebox (e.g.,makebox[2cm]{dashdotted}). MWE:




    mwe




    documentclass[a5paper,twocolumn]{article}
    defdashdotted{xleadershbox to 1em{$- cdot$}hfill $-$}
    begin{document}
    xdashdotted 1par
    xmakebox[2cm]{dashdotted}1par
    xxxxxdashdotted 1par
    xxxxxxxxxxdashdotted 1par
    xxxxxxxxxxxxxxxdashdotted 1
    end{document}





    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',
      autoActivateHeartbeat: false,
      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%2f327982%2fdraw-a-dash-dotted-line%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      36














      The various pre-defined dash patterns are documented in section 15.3.2 Graphic Parameters: Dash Pattern of the manual (for version 3.0.1.a dated 29 August 2015). They are dotted, dashed, dash dot and dash dot dot. Each of these have denser and looser variants, e.g. densely dashed and loosely dotted. Equivalently for the others.



      In addition you can specify a custom pattern using e.g. dash pattern={on 4pt off 1pt on 2pt off 3pt}, which I guess is self explanatory.



      documentclass{article}
      usepackage{tikz}

      begin{document}
      begin{tikzpicture}
      draw [thick,dash dot] (0,1) -- (5,1);
      draw [thick,dash pattern={on 7pt off 2pt on 1pt off 3pt}] (0,0) -- (5,0);
      end{tikzpicture}

      end{document}


      enter image description here



      Addendum



      If you want to put a line like this in the text, and aligned better to the surrounding text, then you can add the baseline=<length> option to the tikzpicture. By default the bottom end of the tikzpicture is placed on the baseline of the surrounding text. If you add baseline=10pt then the tikzpicture will be placed so that y=10pt in its internal coordinate system is on the baseline of the surrounding text.



      Here is an example. tikz is a short form of the tikzpicture environment, intended for simple pictures placed in the text.



      documentclass{article}
      usepackage{tikz}

      begin{document}
      Lorem ipsum tikzdraw [thick,dash dot] (0,0) -- (3,0); dolor sit amet

      Lorem ipsum tikz[baseline=-0.5ex]draw [thick,dash dot] (0,0) -- (3,0); dolor sit amet
      end{document}


      enter image description here






      share|improve this answer


























      • (x1, y1) and (x2, y2) seem to be coordinates. Is it right, that the coordinate with the lower x part is set to be wherever the environment ends? My tests tell so. Than how can I set the line in the middle line high, like appearing like this: before --- after

        – Ben
        Sep 4 '16 at 20:21











      • *wherever the environment starts

        – Ben
        Sep 4 '16 at 20:27






      • 1





        @Ben I'm not entirely sure what you mean, but I think you're after the baseline key, see the addition to my answer.

        – Torbjørn T.
        Sep 4 '16 at 20:32











      • I am sorry, but how can it be written if the length is needed to be a fraction of textwidth or 2cm for example?

        – Diaa
        Sep 4 '16 at 20:40






      • 2





        @DiaaAbidou As mentioned above, the default unit vectors are 1cm, so a line from (0,0) to (2,0) would be 2cm. That said, you can also use explicit units, so draw (0,0) -- (2cm,0); works. And TeX lengths work as well, so you can say e.g. draw (0,0) -- (0.1linewidth,0);

        – Torbjørn T.
        Sep 4 '16 at 20:52


















      36














      The various pre-defined dash patterns are documented in section 15.3.2 Graphic Parameters: Dash Pattern of the manual (for version 3.0.1.a dated 29 August 2015). They are dotted, dashed, dash dot and dash dot dot. Each of these have denser and looser variants, e.g. densely dashed and loosely dotted. Equivalently for the others.



      In addition you can specify a custom pattern using e.g. dash pattern={on 4pt off 1pt on 2pt off 3pt}, which I guess is self explanatory.



      documentclass{article}
      usepackage{tikz}

      begin{document}
      begin{tikzpicture}
      draw [thick,dash dot] (0,1) -- (5,1);
      draw [thick,dash pattern={on 7pt off 2pt on 1pt off 3pt}] (0,0) -- (5,0);
      end{tikzpicture}

      end{document}


      enter image description here



      Addendum



      If you want to put a line like this in the text, and aligned better to the surrounding text, then you can add the baseline=<length> option to the tikzpicture. By default the bottom end of the tikzpicture is placed on the baseline of the surrounding text. If you add baseline=10pt then the tikzpicture will be placed so that y=10pt in its internal coordinate system is on the baseline of the surrounding text.



      Here is an example. tikz is a short form of the tikzpicture environment, intended for simple pictures placed in the text.



      documentclass{article}
      usepackage{tikz}

      begin{document}
      Lorem ipsum tikzdraw [thick,dash dot] (0,0) -- (3,0); dolor sit amet

      Lorem ipsum tikz[baseline=-0.5ex]draw [thick,dash dot] (0,0) -- (3,0); dolor sit amet
      end{document}


      enter image description here






      share|improve this answer


























      • (x1, y1) and (x2, y2) seem to be coordinates. Is it right, that the coordinate with the lower x part is set to be wherever the environment ends? My tests tell so. Than how can I set the line in the middle line high, like appearing like this: before --- after

        – Ben
        Sep 4 '16 at 20:21











      • *wherever the environment starts

        – Ben
        Sep 4 '16 at 20:27






      • 1





        @Ben I'm not entirely sure what you mean, but I think you're after the baseline key, see the addition to my answer.

        – Torbjørn T.
        Sep 4 '16 at 20:32











      • I am sorry, but how can it be written if the length is needed to be a fraction of textwidth or 2cm for example?

        – Diaa
        Sep 4 '16 at 20:40






      • 2





        @DiaaAbidou As mentioned above, the default unit vectors are 1cm, so a line from (0,0) to (2,0) would be 2cm. That said, you can also use explicit units, so draw (0,0) -- (2cm,0); works. And TeX lengths work as well, so you can say e.g. draw (0,0) -- (0.1linewidth,0);

        – Torbjørn T.
        Sep 4 '16 at 20:52
















      36












      36








      36







      The various pre-defined dash patterns are documented in section 15.3.2 Graphic Parameters: Dash Pattern of the manual (for version 3.0.1.a dated 29 August 2015). They are dotted, dashed, dash dot and dash dot dot. Each of these have denser and looser variants, e.g. densely dashed and loosely dotted. Equivalently for the others.



      In addition you can specify a custom pattern using e.g. dash pattern={on 4pt off 1pt on 2pt off 3pt}, which I guess is self explanatory.



      documentclass{article}
      usepackage{tikz}

      begin{document}
      begin{tikzpicture}
      draw [thick,dash dot] (0,1) -- (5,1);
      draw [thick,dash pattern={on 7pt off 2pt on 1pt off 3pt}] (0,0) -- (5,0);
      end{tikzpicture}

      end{document}


      enter image description here



      Addendum



      If you want to put a line like this in the text, and aligned better to the surrounding text, then you can add the baseline=<length> option to the tikzpicture. By default the bottom end of the tikzpicture is placed on the baseline of the surrounding text. If you add baseline=10pt then the tikzpicture will be placed so that y=10pt in its internal coordinate system is on the baseline of the surrounding text.



      Here is an example. tikz is a short form of the tikzpicture environment, intended for simple pictures placed in the text.



      documentclass{article}
      usepackage{tikz}

      begin{document}
      Lorem ipsum tikzdraw [thick,dash dot] (0,0) -- (3,0); dolor sit amet

      Lorem ipsum tikz[baseline=-0.5ex]draw [thick,dash dot] (0,0) -- (3,0); dolor sit amet
      end{document}


      enter image description here






      share|improve this answer















      The various pre-defined dash patterns are documented in section 15.3.2 Graphic Parameters: Dash Pattern of the manual (for version 3.0.1.a dated 29 August 2015). They are dotted, dashed, dash dot and dash dot dot. Each of these have denser and looser variants, e.g. densely dashed and loosely dotted. Equivalently for the others.



      In addition you can specify a custom pattern using e.g. dash pattern={on 4pt off 1pt on 2pt off 3pt}, which I guess is self explanatory.



      documentclass{article}
      usepackage{tikz}

      begin{document}
      begin{tikzpicture}
      draw [thick,dash dot] (0,1) -- (5,1);
      draw [thick,dash pattern={on 7pt off 2pt on 1pt off 3pt}] (0,0) -- (5,0);
      end{tikzpicture}

      end{document}


      enter image description here



      Addendum



      If you want to put a line like this in the text, and aligned better to the surrounding text, then you can add the baseline=<length> option to the tikzpicture. By default the bottom end of the tikzpicture is placed on the baseline of the surrounding text. If you add baseline=10pt then the tikzpicture will be placed so that y=10pt in its internal coordinate system is on the baseline of the surrounding text.



      Here is an example. tikz is a short form of the tikzpicture environment, intended for simple pictures placed in the text.



      documentclass{article}
      usepackage{tikz}

      begin{document}
      Lorem ipsum tikzdraw [thick,dash dot] (0,0) -- (3,0); dolor sit amet

      Lorem ipsum tikz[baseline=-0.5ex]draw [thick,dash dot] (0,0) -- (3,0); dolor sit amet
      end{document}


      enter image description here







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Sep 4 '16 at 20:31

























      answered Sep 4 '16 at 19:51









      Torbjørn T.Torbjørn T.

      159k13259447




      159k13259447













      • (x1, y1) and (x2, y2) seem to be coordinates. Is it right, that the coordinate with the lower x part is set to be wherever the environment ends? My tests tell so. Than how can I set the line in the middle line high, like appearing like this: before --- after

        – Ben
        Sep 4 '16 at 20:21











      • *wherever the environment starts

        – Ben
        Sep 4 '16 at 20:27






      • 1





        @Ben I'm not entirely sure what you mean, but I think you're after the baseline key, see the addition to my answer.

        – Torbjørn T.
        Sep 4 '16 at 20:32











      • I am sorry, but how can it be written if the length is needed to be a fraction of textwidth or 2cm for example?

        – Diaa
        Sep 4 '16 at 20:40






      • 2





        @DiaaAbidou As mentioned above, the default unit vectors are 1cm, so a line from (0,0) to (2,0) would be 2cm. That said, you can also use explicit units, so draw (0,0) -- (2cm,0); works. And TeX lengths work as well, so you can say e.g. draw (0,0) -- (0.1linewidth,0);

        – Torbjørn T.
        Sep 4 '16 at 20:52





















      • (x1, y1) and (x2, y2) seem to be coordinates. Is it right, that the coordinate with the lower x part is set to be wherever the environment ends? My tests tell so. Than how can I set the line in the middle line high, like appearing like this: before --- after

        – Ben
        Sep 4 '16 at 20:21











      • *wherever the environment starts

        – Ben
        Sep 4 '16 at 20:27






      • 1





        @Ben I'm not entirely sure what you mean, but I think you're after the baseline key, see the addition to my answer.

        – Torbjørn T.
        Sep 4 '16 at 20:32











      • I am sorry, but how can it be written if the length is needed to be a fraction of textwidth or 2cm for example?

        – Diaa
        Sep 4 '16 at 20:40






      • 2





        @DiaaAbidou As mentioned above, the default unit vectors are 1cm, so a line from (0,0) to (2,0) would be 2cm. That said, you can also use explicit units, so draw (0,0) -- (2cm,0); works. And TeX lengths work as well, so you can say e.g. draw (0,0) -- (0.1linewidth,0);

        – Torbjørn T.
        Sep 4 '16 at 20:52



















      (x1, y1) and (x2, y2) seem to be coordinates. Is it right, that the coordinate with the lower x part is set to be wherever the environment ends? My tests tell so. Than how can I set the line in the middle line high, like appearing like this: before --- after

      – Ben
      Sep 4 '16 at 20:21





      (x1, y1) and (x2, y2) seem to be coordinates. Is it right, that the coordinate with the lower x part is set to be wherever the environment ends? My tests tell so. Than how can I set the line in the middle line high, like appearing like this: before --- after

      – Ben
      Sep 4 '16 at 20:21













      *wherever the environment starts

      – Ben
      Sep 4 '16 at 20:27





      *wherever the environment starts

      – Ben
      Sep 4 '16 at 20:27




      1




      1





      @Ben I'm not entirely sure what you mean, but I think you're after the baseline key, see the addition to my answer.

      – Torbjørn T.
      Sep 4 '16 at 20:32





      @Ben I'm not entirely sure what you mean, but I think you're after the baseline key, see the addition to my answer.

      – Torbjørn T.
      Sep 4 '16 at 20:32













      I am sorry, but how can it be written if the length is needed to be a fraction of textwidth or 2cm for example?

      – Diaa
      Sep 4 '16 at 20:40





      I am sorry, but how can it be written if the length is needed to be a fraction of textwidth or 2cm for example?

      – Diaa
      Sep 4 '16 at 20:40




      2




      2





      @DiaaAbidou As mentioned above, the default unit vectors are 1cm, so a line from (0,0) to (2,0) would be 2cm. That said, you can also use explicit units, so draw (0,0) -- (2cm,0); works. And TeX lengths work as well, so you can say e.g. draw (0,0) -- (0.1linewidth,0);

      – Torbjørn T.
      Sep 4 '16 at 20:52







      @DiaaAbidou As mentioned above, the default unit vectors are 1cm, so a line from (0,0) to (2,0) would be 2cm. That said, you can also use explicit units, so draw (0,0) -- (2cm,0); works. And TeX lengths work as well, so you can say e.g. draw (0,0) -- (0.1linewidth,0);

      – Torbjørn T.
      Sep 4 '16 at 20:52













      8














      Here is a version using leaders. While all the parameters can be changed, the main ones are dashdotline{<length>} to draw the line, with these configurations: dashfrac{<percent of repetition used by dash>}; replength=<repetition-length>relax.



      documentclass[10pt]{article}
      newlengthreplength
      newcommandrepfrac{.40}% PERCENT OF REPETITION USED BY DASH
      newcommanddashfrac[1]{renewcommandrepfrac{#1}}% MACRO TO ALTER repfrac
      setlengthreplength{8.5pt}% REPITITION LENGTH
      newcommandrulewidth{.6pt}% DASH WIDTH
      defdashht{.5dimexprhtstrutbox-dpstrutboxrelax}
      newcommandtdashfill[1][repfrac]{cleadershbox to replength{%
      smash{rule[dashht]{repfracreplength}{rulewidth}%
      kern.5dimexprreplength-repfracreplength-2.5ptrelax%
      raisebox{dimexprdashht-.3pt}{.}}}hfill}
      newcommanddashdotline[1]{%
      makebox[#1][l]{tdashfillhfil}}
      begin{document}
      xdashdotline{2in}ypar
      replength 17.5pt
      xdashdotline{1in}ypar
      dashfrac{.66}
      xdashdotline{1in}y
      end{document}


      enter image description here






      share|improve this answer




























        8














        Here is a version using leaders. While all the parameters can be changed, the main ones are dashdotline{<length>} to draw the line, with these configurations: dashfrac{<percent of repetition used by dash>}; replength=<repetition-length>relax.



        documentclass[10pt]{article}
        newlengthreplength
        newcommandrepfrac{.40}% PERCENT OF REPETITION USED BY DASH
        newcommanddashfrac[1]{renewcommandrepfrac{#1}}% MACRO TO ALTER repfrac
        setlengthreplength{8.5pt}% REPITITION LENGTH
        newcommandrulewidth{.6pt}% DASH WIDTH
        defdashht{.5dimexprhtstrutbox-dpstrutboxrelax}
        newcommandtdashfill[1][repfrac]{cleadershbox to replength{%
        smash{rule[dashht]{repfracreplength}{rulewidth}%
        kern.5dimexprreplength-repfracreplength-2.5ptrelax%
        raisebox{dimexprdashht-.3pt}{.}}}hfill}
        newcommanddashdotline[1]{%
        makebox[#1][l]{tdashfillhfil}}
        begin{document}
        xdashdotline{2in}ypar
        replength 17.5pt
        xdashdotline{1in}ypar
        dashfrac{.66}
        xdashdotline{1in}y
        end{document}


        enter image description here






        share|improve this answer


























          8












          8








          8







          Here is a version using leaders. While all the parameters can be changed, the main ones are dashdotline{<length>} to draw the line, with these configurations: dashfrac{<percent of repetition used by dash>}; replength=<repetition-length>relax.



          documentclass[10pt]{article}
          newlengthreplength
          newcommandrepfrac{.40}% PERCENT OF REPETITION USED BY DASH
          newcommanddashfrac[1]{renewcommandrepfrac{#1}}% MACRO TO ALTER repfrac
          setlengthreplength{8.5pt}% REPITITION LENGTH
          newcommandrulewidth{.6pt}% DASH WIDTH
          defdashht{.5dimexprhtstrutbox-dpstrutboxrelax}
          newcommandtdashfill[1][repfrac]{cleadershbox to replength{%
          smash{rule[dashht]{repfracreplength}{rulewidth}%
          kern.5dimexprreplength-repfracreplength-2.5ptrelax%
          raisebox{dimexprdashht-.3pt}{.}}}hfill}
          newcommanddashdotline[1]{%
          makebox[#1][l]{tdashfillhfil}}
          begin{document}
          xdashdotline{2in}ypar
          replength 17.5pt
          xdashdotline{1in}ypar
          dashfrac{.66}
          xdashdotline{1in}y
          end{document}


          enter image description here






          share|improve this answer













          Here is a version using leaders. While all the parameters can be changed, the main ones are dashdotline{<length>} to draw the line, with these configurations: dashfrac{<percent of repetition used by dash>}; replength=<repetition-length>relax.



          documentclass[10pt]{article}
          newlengthreplength
          newcommandrepfrac{.40}% PERCENT OF REPETITION USED BY DASH
          newcommanddashfrac[1]{renewcommandrepfrac{#1}}% MACRO TO ALTER repfrac
          setlengthreplength{8.5pt}% REPITITION LENGTH
          newcommandrulewidth{.6pt}% DASH WIDTH
          defdashht{.5dimexprhtstrutbox-dpstrutboxrelax}
          newcommandtdashfill[1][repfrac]{cleadershbox to replength{%
          smash{rule[dashht]{repfracreplength}{rulewidth}%
          kern.5dimexprreplength-repfracreplength-2.5ptrelax%
          raisebox{dimexprdashht-.3pt}{.}}}hfill}
          newcommanddashdotline[1]{%
          makebox[#1][l]{tdashfillhfil}}
          begin{document}
          xdashdotline{2in}ypar
          replength 17.5pt
          xdashdotline{1in}ypar
          dashfrac{.66}
          xdashdotline{1in}y
          end{document}


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 5 '16 at 0:27









          Steven B. SegletesSteven B. Segletes

          163k9207420




          163k9207420























              0














              Yet another solution with leaders, not perfect but as simple as possible:



              xleadershbox to 1em{$- cdot$}hfill $-$


              If you will use this often, define some macro as dashdotted,
              If you want a specific length instead of filling the line, simply enclose it in a makebox (e.g.,makebox[2cm]{dashdotted}). MWE:




              mwe




              documentclass[a5paper,twocolumn]{article}
              defdashdotted{xleadershbox to 1em{$- cdot$}hfill $-$}
              begin{document}
              xdashdotted 1par
              xmakebox[2cm]{dashdotted}1par
              xxxxxdashdotted 1par
              xxxxxxxxxxdashdotted 1par
              xxxxxxxxxxxxxxxdashdotted 1
              end{document}





              share|improve this answer




























                0














                Yet another solution with leaders, not perfect but as simple as possible:



                xleadershbox to 1em{$- cdot$}hfill $-$


                If you will use this often, define some macro as dashdotted,
                If you want a specific length instead of filling the line, simply enclose it in a makebox (e.g.,makebox[2cm]{dashdotted}). MWE:




                mwe




                documentclass[a5paper,twocolumn]{article}
                defdashdotted{xleadershbox to 1em{$- cdot$}hfill $-$}
                begin{document}
                xdashdotted 1par
                xmakebox[2cm]{dashdotted}1par
                xxxxxdashdotted 1par
                xxxxxxxxxxdashdotted 1par
                xxxxxxxxxxxxxxxdashdotted 1
                end{document}





                share|improve this answer


























                  0












                  0








                  0







                  Yet another solution with leaders, not perfect but as simple as possible:



                  xleadershbox to 1em{$- cdot$}hfill $-$


                  If you will use this often, define some macro as dashdotted,
                  If you want a specific length instead of filling the line, simply enclose it in a makebox (e.g.,makebox[2cm]{dashdotted}). MWE:




                  mwe




                  documentclass[a5paper,twocolumn]{article}
                  defdashdotted{xleadershbox to 1em{$- cdot$}hfill $-$}
                  begin{document}
                  xdashdotted 1par
                  xmakebox[2cm]{dashdotted}1par
                  xxxxxdashdotted 1par
                  xxxxxxxxxxdashdotted 1par
                  xxxxxxxxxxxxxxxdashdotted 1
                  end{document}





                  share|improve this answer













                  Yet another solution with leaders, not perfect but as simple as possible:



                  xleadershbox to 1em{$- cdot$}hfill $-$


                  If you will use this often, define some macro as dashdotted,
                  If you want a specific length instead of filling the line, simply enclose it in a makebox (e.g.,makebox[2cm]{dashdotted}). MWE:




                  mwe




                  documentclass[a5paper,twocolumn]{article}
                  defdashdotted{xleadershbox to 1em{$- cdot$}hfill $-$}
                  begin{document}
                  xdashdotted 1par
                  xmakebox[2cm]{dashdotted}1par
                  xxxxxdashdotted 1par
                  xxxxxxxxxxdashdotted 1par
                  xxxxxxxxxxxxxxxdashdotted 1
                  end{document}






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Sep 5 '16 at 18:06









                  FranFran

                  53.9k6122183




                  53.9k6122183






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f327982%2fdraw-a-dash-dotted-line%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

                      El tren de la libertad Índice Antecedentes "Porque yo decido" Desarrollo de la...

                      Castillo d'Acher Características Menú de navegación

                      Connecting two nodes from the same mother node horizontallyTikZ: What EXACTLY does the the |- notation for...