Creating patternsFilling rectangle in TikZ with more than one colorTikZ: Cropping the Bounding BoxTikz: redefinition of patternsTikZ: Get values for predefined dash patternsCustom and built in TikZ fill patternsChange thickness of TikZ pattern library patternsPatterns in TikZPGFplots ybar patterns not showingCreating random patterns in TikZTikZ/ERD: node (=Entity) label on the insideCustom Fading for Rectangle

How to calculate a conditional PDF in mathematica?

What is this arch-and-tower near a road?

Does Evolution Sage proliferate Blast Zone when played?

How do both sides know the MTU

What units are kpts?

Do I need to be legally qualified to install a Hive smart thermostat?

What is the maximum amount of diamond in one Minecraft game?

Is it possible to spoof an IP address to an exact number?

Platform Event Design when Subscribers are Apex Triggers

Should I hide my travel history to the UK when I apply for an Australian visa?

What can a novel do that film and TV cannot?

how can i make this execution plan more efficient?

Interview Question - Card betting

Did Stalin kill all Soviet officers involved in the Winter War?

Sleepy tired vs physically tired

How to respond to someone who condemns behavior similar to what they exhibit?

What are the differences of checking a self-signed certificate vs ignore it?

Can 4 Joy cons connect to the same Switch?

Should I cheat if the majority does it?

Why do Klingons use cloaking devices?

What is meaning of 4 letter abbreviations in Roman names like Titus Flavius T. f. T. n. Sabinus?

Will electrically joined dipoles of different lengths, at right angles, behave as a multiband antenna?

How did שְׁלֹמֹה (shlomo) become Solomon?

Taking advantage when the HR forgets to communicate the rules



Creating patterns


Filling rectangle in TikZ with more than one colorTikZ: Cropping the Bounding BoxTikz: redefinition of patternsTikZ: Get values for predefined dash patternsCustom and built in TikZ fill patternsChange thickness of TikZ pattern library patternsPatterns in TikZPGFplots ybar patterns not showingCreating random patterns in TikZTikZ/ERD: node (=Entity) label on the insideCustom Fading for Rectangle






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








6















Using north east hatch from the answer to this question Filling rectangle in TikZ with more than one color I wanted to make a north west hatch. However, it has funny teeth I do not know how to get rid of. What is wrong and how can I correct that?



enter image description here



MWE:



documentclassminimal

usepackagetikz

begindocument

begintikzpicture


usetikzlibrarypatterns

makeatletter
tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
pgfqpoint-1pt-1pt% below left
pgfqpointhatchdistancehatchdistance% above right
pgfpointhatchdistance-1pthatchdistance-1pt%

pgfsetcolortikz@pattern@color
pgfsetlinewidthhatchthickness
pgfpathmovetopgfqpoint0pt0pt
pgfpathlinetopgfqpointhatchdistancehatchdistance
pgfusepathstroke

pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
pgfqpoint-1pt-1pt% below left
pgfqpointhatchdistancehatchdistance% above right
pgfpointhatchdistance-1pthatchdistance-1pt%

pgfsetcolortikz@pattern@color
pgfsetlinewidthhatchthickness
pgfpathmovetopgfqpointhatchdistance0pt
pgfpathlinetopgfqpoint0pthatchdistance
pgfusepathstroke

makeatother

draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (2,0) rectangle +(1,1);


endtikzpicture
enddocument









share|improve this question




























    6















    Using north east hatch from the answer to this question Filling rectangle in TikZ with more than one color I wanted to make a north west hatch. However, it has funny teeth I do not know how to get rid of. What is wrong and how can I correct that?



    enter image description here



    MWE:



    documentclassminimal

    usepackagetikz

    begindocument

    begintikzpicture


    usetikzlibrarypatterns

    makeatletter
    tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

    pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
    pgfqpoint-1pt-1pt% below left
    pgfqpointhatchdistancehatchdistance% above right
    pgfpointhatchdistance-1pthatchdistance-1pt%

    pgfsetcolortikz@pattern@color
    pgfsetlinewidthhatchthickness
    pgfpathmovetopgfqpoint0pt0pt
    pgfpathlinetopgfqpointhatchdistancehatchdistance
    pgfusepathstroke

    pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
    pgfqpoint-1pt-1pt% below left
    pgfqpointhatchdistancehatchdistance% above right
    pgfpointhatchdistance-1pthatchdistance-1pt%

    pgfsetcolortikz@pattern@color
    pgfsetlinewidthhatchthickness
    pgfpathmovetopgfqpointhatchdistance0pt
    pgfpathlinetopgfqpoint0pthatchdistance
    pgfusepathstroke

    makeatother

    draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
    draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (2,0) rectangle +(1,1);


    endtikzpicture
    enddocument









    share|improve this question
























      6












      6








      6








      Using north east hatch from the answer to this question Filling rectangle in TikZ with more than one color I wanted to make a north west hatch. However, it has funny teeth I do not know how to get rid of. What is wrong and how can I correct that?



      enter image description here



      MWE:



      documentclassminimal

      usepackagetikz

      begindocument

      begintikzpicture


      usetikzlibrarypatterns

      makeatletter
      tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

      pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
      pgfqpoint-1pt-1pt% below left
      pgfqpointhatchdistancehatchdistance% above right
      pgfpointhatchdistance-1pthatchdistance-1pt%

      pgfsetcolortikz@pattern@color
      pgfsetlinewidthhatchthickness
      pgfpathmovetopgfqpoint0pt0pt
      pgfpathlinetopgfqpointhatchdistancehatchdistance
      pgfusepathstroke

      pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
      pgfqpoint-1pt-1pt% below left
      pgfqpointhatchdistancehatchdistance% above right
      pgfpointhatchdistance-1pthatchdistance-1pt%

      pgfsetcolortikz@pattern@color
      pgfsetlinewidthhatchthickness
      pgfpathmovetopgfqpointhatchdistance0pt
      pgfpathlinetopgfqpoint0pthatchdistance
      pgfusepathstroke

      makeatother

      draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
      draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (2,0) rectangle +(1,1);


      endtikzpicture
      enddocument









      share|improve this question














      Using north east hatch from the answer to this question Filling rectangle in TikZ with more than one color I wanted to make a north west hatch. However, it has funny teeth I do not know how to get rid of. What is wrong and how can I correct that?



      enter image description here



      MWE:



      documentclassminimal

      usepackagetikz

      begindocument

      begintikzpicture


      usetikzlibrarypatterns

      makeatletter
      tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

      pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
      pgfqpoint-1pt-1pt% below left
      pgfqpointhatchdistancehatchdistance% above right
      pgfpointhatchdistance-1pthatchdistance-1pt%

      pgfsetcolortikz@pattern@color
      pgfsetlinewidthhatchthickness
      pgfpathmovetopgfqpoint0pt0pt
      pgfpathlinetopgfqpointhatchdistancehatchdistance
      pgfusepathstroke

      pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
      pgfqpoint-1pt-1pt% below left
      pgfqpointhatchdistancehatchdistance% above right
      pgfpointhatchdistance-1pthatchdistance-1pt%

      pgfsetcolortikz@pattern@color
      pgfsetlinewidthhatchthickness
      pgfpathmovetopgfqpointhatchdistance0pt
      pgfpathlinetopgfqpoint0pthatchdistance
      pgfusepathstroke

      makeatother

      draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
      draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (2,0) rectangle +(1,1);


      endtikzpicture
      enddocument






      tikz-pgf






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 8 hours ago









      PygmalionPygmalion

      2,4933 gold badges26 silver badges54 bronze badges




      2,4933 gold badges26 silver badges54 bronze badges




















          2 Answers
          2






          active

          oldest

          votes


















          5














          By enlarging the bounding box sufficiently, the problem is solved.



          According to my calculations, it must be enlarged by at least 71%.



          screenshot



          To simplify, I expanded it by an integer multiple of hatchdistance.



          pgfqpoint-hatchdistance-hatchdistance% below left
          pgfqpoint2hatchdistance2hatchdistance% above right


          hatch not really straight



          screenshot



          The hatches are not perfectly straight (like the default ones in the patterns library) but they remain unchanged by scaling as shown in the above result.



          Straight hatch



          To do this, I enlarged the line that traces the hatching of an integer multiple hatchdistance (noninteger multiples pose problems that I have not yet understood).



          pgfpathmovetopgfqpoint2hatchdistance-hatchdistance
          pgfpathlinetopgfqpoint-hatchdistance2hatchdistance


          screenshot



          Code for really straight hatch:



          documentclass[tikz,border=5mm]standalone

          begindocument

          begintikzpicture
          usetikzlibrarypatterns

          makeatletter
          tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

          pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
          pgfqpoint-1pt-1pt% below left
          pgfqpointhatchdistancehatchdistance% above right
          pgfpointhatchdistance-1pthatchdistance-1pt%

          pgfsetcolortikz@pattern@color
          pgfsetlinewidthhatchthickness
          pgfpathmovetopgfqpoint0pt0pt
          pgfpathlinetopgfqpointhatchdistancehatchdistance
          pgfusepathstroke

          pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
          pgfqpoint-hatchdistance-hatchdistance% below left
          pgfqpoint2hatchdistance2hatchdistance% above right
          pgfpointhatchdistancehatchdistance%

          pgfsetcolortikz@pattern@color
          pgfsetlinewidthhatchthickness
          pgfpathmovetopgfqpoint2hatchdistance-hatchdistance
          pgfpathlinetopgfqpoint-hatchdistance2hatchdistance
          pgfusepathstroke

          makeatother


          draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
          draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange,scale=2] (.6,0) rectangle +(1,1);

          endtikzpicture
          enddocument


          Code for hatch that are not really straight:



          documentclass[tikz,border=5mm]standalone

          begindocument

          begintikzpicture
          usetikzlibrarypatterns

          makeatletter
          tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

          pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
          pgfqpoint-1pt-1pt% below left
          pgfqpointhatchdistancehatchdistance% above right
          pgfpointhatchdistance-1pthatchdistance-1pt%

          pgfsetcolortikz@pattern@color
          pgfsetlinewidthhatchthickness
          pgfpathmovetopgfqpoint0pt0pt
          pgfpathlinetopgfqpointhatchdistancehatchdistance
          pgfusepathstroke

          pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
          pgfqpoint-hatchdistance-hatchdistance% below left
          pgfqpoint2hatchdistance2hatchdistance% above right
          pgfpointhatchdistance-1pthatchdistance-1pt%

          pgfsetcolortikz@pattern@color
          pgfsetlinewidthhatchthickness
          pgfpathmovetopgfqpointhatchdistance0pt
          pgfpathlinetopgfqpoint0pthatchdistance
          pgfusepathstroke

          makeatother

          draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
          draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange,scale=2] (1,0) rectangle +(1,1);

          endtikzpicture
          enddocument





          share|improve this answer
































            5














            You do what one usually does: define the cell size a bit smaller than what the path actually covers. The problem is that if the width of the line exceeds 0.5pt, an overshoot by 1pt is no longer sufficient. So one may want to use a more generous overshoot. The following may be a bit "too generous" (but being
            generous has no real sideeffects here AFAIK), and this one seems to work for many viewers and zoom levels, i.e. some of the things but not all in your code are also viewer issues.



            documentclass[tikz,border=3.14mm]standalone

            begindocument

            begintikzpicture


            usetikzlibrarypatterns

            makeatletter
            tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

            pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
            pgfqpoint-hatchthickness-hatchthickness% below left
            pgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness% above right
            pgfpointhatchdistancehatchdistance%

            pgfsetcolortikz@pattern@color
            pgfsetlinewidthhatchthickness
            pgfpathmovetopgfqpoint-hatchthickness-hatchthickness
            pgfpathlinetopgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness
            pgfusepathstroke

            pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
            pgfqpoint-hatchthickness-hatchthickness% below left
            pgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness% above right
            pgfpointhatchdistancehatchdistance%

            pgfsetcolortikz@pattern@color
            pgfsetlinewidthhatchthickness
            pgfpathmovetopgfqpointhatchdistance+hatchthickness-hatchthickness
            pgfpathlinetopgfqpoint-hatchthicknesshatchdistance+hatchthickness
            pgfusepathstroke

            makeatother

            draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
            draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (2,0) rectangle +(1,1);


            endtikzpicture
            enddocument


            enter image description here






            share|improve this answer

























            • When I use your solution I get teeth, even bigger ones, on the other side?!

              – Pygmalion
              5 hours ago











            • @Pygmalion Hmmh, strange. I slightly adjusted the parameters. Is it better now?

              – marmot
              2 hours ago














            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%2f498376%2fcreating-patterns%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5














            By enlarging the bounding box sufficiently, the problem is solved.



            According to my calculations, it must be enlarged by at least 71%.



            screenshot



            To simplify, I expanded it by an integer multiple of hatchdistance.



            pgfqpoint-hatchdistance-hatchdistance% below left
            pgfqpoint2hatchdistance2hatchdistance% above right


            hatch not really straight



            screenshot



            The hatches are not perfectly straight (like the default ones in the patterns library) but they remain unchanged by scaling as shown in the above result.



            Straight hatch



            To do this, I enlarged the line that traces the hatching of an integer multiple hatchdistance (noninteger multiples pose problems that I have not yet understood).



            pgfpathmovetopgfqpoint2hatchdistance-hatchdistance
            pgfpathlinetopgfqpoint-hatchdistance2hatchdistance


            screenshot



            Code for really straight hatch:



            documentclass[tikz,border=5mm]standalone

            begindocument

            begintikzpicture
            usetikzlibrarypatterns

            makeatletter
            tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

            pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
            pgfqpoint-1pt-1pt% below left
            pgfqpointhatchdistancehatchdistance% above right
            pgfpointhatchdistance-1pthatchdistance-1pt%

            pgfsetcolortikz@pattern@color
            pgfsetlinewidthhatchthickness
            pgfpathmovetopgfqpoint0pt0pt
            pgfpathlinetopgfqpointhatchdistancehatchdistance
            pgfusepathstroke

            pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
            pgfqpoint-hatchdistance-hatchdistance% below left
            pgfqpoint2hatchdistance2hatchdistance% above right
            pgfpointhatchdistancehatchdistance%

            pgfsetcolortikz@pattern@color
            pgfsetlinewidthhatchthickness
            pgfpathmovetopgfqpoint2hatchdistance-hatchdistance
            pgfpathlinetopgfqpoint-hatchdistance2hatchdistance
            pgfusepathstroke

            makeatother


            draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
            draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange,scale=2] (.6,0) rectangle +(1,1);

            endtikzpicture
            enddocument


            Code for hatch that are not really straight:



            documentclass[tikz,border=5mm]standalone

            begindocument

            begintikzpicture
            usetikzlibrarypatterns

            makeatletter
            tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

            pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
            pgfqpoint-1pt-1pt% below left
            pgfqpointhatchdistancehatchdistance% above right
            pgfpointhatchdistance-1pthatchdistance-1pt%

            pgfsetcolortikz@pattern@color
            pgfsetlinewidthhatchthickness
            pgfpathmovetopgfqpoint0pt0pt
            pgfpathlinetopgfqpointhatchdistancehatchdistance
            pgfusepathstroke

            pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
            pgfqpoint-hatchdistance-hatchdistance% below left
            pgfqpoint2hatchdistance2hatchdistance% above right
            pgfpointhatchdistance-1pthatchdistance-1pt%

            pgfsetcolortikz@pattern@color
            pgfsetlinewidthhatchthickness
            pgfpathmovetopgfqpointhatchdistance0pt
            pgfpathlinetopgfqpoint0pthatchdistance
            pgfusepathstroke

            makeatother

            draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
            draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange,scale=2] (1,0) rectangle +(1,1);

            endtikzpicture
            enddocument





            share|improve this answer





























              5














              By enlarging the bounding box sufficiently, the problem is solved.



              According to my calculations, it must be enlarged by at least 71%.



              screenshot



              To simplify, I expanded it by an integer multiple of hatchdistance.



              pgfqpoint-hatchdistance-hatchdistance% below left
              pgfqpoint2hatchdistance2hatchdistance% above right


              hatch not really straight



              screenshot



              The hatches are not perfectly straight (like the default ones in the patterns library) but they remain unchanged by scaling as shown in the above result.



              Straight hatch



              To do this, I enlarged the line that traces the hatching of an integer multiple hatchdistance (noninteger multiples pose problems that I have not yet understood).



              pgfpathmovetopgfqpoint2hatchdistance-hatchdistance
              pgfpathlinetopgfqpoint-hatchdistance2hatchdistance


              screenshot



              Code for really straight hatch:



              documentclass[tikz,border=5mm]standalone

              begindocument

              begintikzpicture
              usetikzlibrarypatterns

              makeatletter
              tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

              pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
              pgfqpoint-1pt-1pt% below left
              pgfqpointhatchdistancehatchdistance% above right
              pgfpointhatchdistance-1pthatchdistance-1pt%

              pgfsetcolortikz@pattern@color
              pgfsetlinewidthhatchthickness
              pgfpathmovetopgfqpoint0pt0pt
              pgfpathlinetopgfqpointhatchdistancehatchdistance
              pgfusepathstroke

              pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
              pgfqpoint-hatchdistance-hatchdistance% below left
              pgfqpoint2hatchdistance2hatchdistance% above right
              pgfpointhatchdistancehatchdistance%

              pgfsetcolortikz@pattern@color
              pgfsetlinewidthhatchthickness
              pgfpathmovetopgfqpoint2hatchdistance-hatchdistance
              pgfpathlinetopgfqpoint-hatchdistance2hatchdistance
              pgfusepathstroke

              makeatother


              draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
              draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange,scale=2] (.6,0) rectangle +(1,1);

              endtikzpicture
              enddocument


              Code for hatch that are not really straight:



              documentclass[tikz,border=5mm]standalone

              begindocument

              begintikzpicture
              usetikzlibrarypatterns

              makeatletter
              tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

              pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
              pgfqpoint-1pt-1pt% below left
              pgfqpointhatchdistancehatchdistance% above right
              pgfpointhatchdistance-1pthatchdistance-1pt%

              pgfsetcolortikz@pattern@color
              pgfsetlinewidthhatchthickness
              pgfpathmovetopgfqpoint0pt0pt
              pgfpathlinetopgfqpointhatchdistancehatchdistance
              pgfusepathstroke

              pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
              pgfqpoint-hatchdistance-hatchdistance% below left
              pgfqpoint2hatchdistance2hatchdistance% above right
              pgfpointhatchdistance-1pthatchdistance-1pt%

              pgfsetcolortikz@pattern@color
              pgfsetlinewidthhatchthickness
              pgfpathmovetopgfqpointhatchdistance0pt
              pgfpathlinetopgfqpoint0pthatchdistance
              pgfusepathstroke

              makeatother

              draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
              draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange,scale=2] (1,0) rectangle +(1,1);

              endtikzpicture
              enddocument





              share|improve this answer



























                5












                5








                5







                By enlarging the bounding box sufficiently, the problem is solved.



                According to my calculations, it must be enlarged by at least 71%.



                screenshot



                To simplify, I expanded it by an integer multiple of hatchdistance.



                pgfqpoint-hatchdistance-hatchdistance% below left
                pgfqpoint2hatchdistance2hatchdistance% above right


                hatch not really straight



                screenshot



                The hatches are not perfectly straight (like the default ones in the patterns library) but they remain unchanged by scaling as shown in the above result.



                Straight hatch



                To do this, I enlarged the line that traces the hatching of an integer multiple hatchdistance (noninteger multiples pose problems that I have not yet understood).



                pgfpathmovetopgfqpoint2hatchdistance-hatchdistance
                pgfpathlinetopgfqpoint-hatchdistance2hatchdistance


                screenshot



                Code for really straight hatch:



                documentclass[tikz,border=5mm]standalone

                begindocument

                begintikzpicture
                usetikzlibrarypatterns

                makeatletter
                tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

                pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
                pgfqpoint-1pt-1pt% below left
                pgfqpointhatchdistancehatchdistance% above right
                pgfpointhatchdistance-1pthatchdistance-1pt%

                pgfsetcolortikz@pattern@color
                pgfsetlinewidthhatchthickness
                pgfpathmovetopgfqpoint0pt0pt
                pgfpathlinetopgfqpointhatchdistancehatchdistance
                pgfusepathstroke

                pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
                pgfqpoint-hatchdistance-hatchdistance% below left
                pgfqpoint2hatchdistance2hatchdistance% above right
                pgfpointhatchdistancehatchdistance%

                pgfsetcolortikz@pattern@color
                pgfsetlinewidthhatchthickness
                pgfpathmovetopgfqpoint2hatchdistance-hatchdistance
                pgfpathlinetopgfqpoint-hatchdistance2hatchdistance
                pgfusepathstroke

                makeatother


                draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
                draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange,scale=2] (.6,0) rectangle +(1,1);

                endtikzpicture
                enddocument


                Code for hatch that are not really straight:



                documentclass[tikz,border=5mm]standalone

                begindocument

                begintikzpicture
                usetikzlibrarypatterns

                makeatletter
                tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

                pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
                pgfqpoint-1pt-1pt% below left
                pgfqpointhatchdistancehatchdistance% above right
                pgfpointhatchdistance-1pthatchdistance-1pt%

                pgfsetcolortikz@pattern@color
                pgfsetlinewidthhatchthickness
                pgfpathmovetopgfqpoint0pt0pt
                pgfpathlinetopgfqpointhatchdistancehatchdistance
                pgfusepathstroke

                pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
                pgfqpoint-hatchdistance-hatchdistance% below left
                pgfqpoint2hatchdistance2hatchdistance% above right
                pgfpointhatchdistance-1pthatchdistance-1pt%

                pgfsetcolortikz@pattern@color
                pgfsetlinewidthhatchthickness
                pgfpathmovetopgfqpointhatchdistance0pt
                pgfpathlinetopgfqpoint0pthatchdistance
                pgfusepathstroke

                makeatother

                draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
                draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange,scale=2] (1,0) rectangle +(1,1);

                endtikzpicture
                enddocument





                share|improve this answer















                By enlarging the bounding box sufficiently, the problem is solved.



                According to my calculations, it must be enlarged by at least 71%.



                screenshot



                To simplify, I expanded it by an integer multiple of hatchdistance.



                pgfqpoint-hatchdistance-hatchdistance% below left
                pgfqpoint2hatchdistance2hatchdistance% above right


                hatch not really straight



                screenshot



                The hatches are not perfectly straight (like the default ones in the patterns library) but they remain unchanged by scaling as shown in the above result.



                Straight hatch



                To do this, I enlarged the line that traces the hatching of an integer multiple hatchdistance (noninteger multiples pose problems that I have not yet understood).



                pgfpathmovetopgfqpoint2hatchdistance-hatchdistance
                pgfpathlinetopgfqpoint-hatchdistance2hatchdistance


                screenshot



                Code for really straight hatch:



                documentclass[tikz,border=5mm]standalone

                begindocument

                begintikzpicture
                usetikzlibrarypatterns

                makeatletter
                tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

                pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
                pgfqpoint-1pt-1pt% below left
                pgfqpointhatchdistancehatchdistance% above right
                pgfpointhatchdistance-1pthatchdistance-1pt%

                pgfsetcolortikz@pattern@color
                pgfsetlinewidthhatchthickness
                pgfpathmovetopgfqpoint0pt0pt
                pgfpathlinetopgfqpointhatchdistancehatchdistance
                pgfusepathstroke

                pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
                pgfqpoint-hatchdistance-hatchdistance% below left
                pgfqpoint2hatchdistance2hatchdistance% above right
                pgfpointhatchdistancehatchdistance%

                pgfsetcolortikz@pattern@color
                pgfsetlinewidthhatchthickness
                pgfpathmovetopgfqpoint2hatchdistance-hatchdistance
                pgfpathlinetopgfqpoint-hatchdistance2hatchdistance
                pgfusepathstroke

                makeatother


                draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
                draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange,scale=2] (.6,0) rectangle +(1,1);

                endtikzpicture
                enddocument


                Code for hatch that are not really straight:



                documentclass[tikz,border=5mm]standalone

                begindocument

                begintikzpicture
                usetikzlibrarypatterns

                makeatletter
                tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

                pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
                pgfqpoint-1pt-1pt% below left
                pgfqpointhatchdistancehatchdistance% above right
                pgfpointhatchdistance-1pthatchdistance-1pt%

                pgfsetcolortikz@pattern@color
                pgfsetlinewidthhatchthickness
                pgfpathmovetopgfqpoint0pt0pt
                pgfpathlinetopgfqpointhatchdistancehatchdistance
                pgfusepathstroke

                pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
                pgfqpoint-hatchdistance-hatchdistance% below left
                pgfqpoint2hatchdistance2hatchdistance% above right
                pgfpointhatchdistance-1pthatchdistance-1pt%

                pgfsetcolortikz@pattern@color
                pgfsetlinewidthhatchthickness
                pgfpathmovetopgfqpointhatchdistance0pt
                pgfpathlinetopgfqpoint0pthatchdistance
                pgfusepathstroke

                makeatother

                draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
                draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange,scale=2] (1,0) rectangle +(1,1);

                endtikzpicture
                enddocument






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 4 hours ago

























                answered 7 hours ago









                AndréCAndréC

                10.8k1 gold badge15 silver badges50 bronze badges




                10.8k1 gold badge15 silver badges50 bronze badges























                    5














                    You do what one usually does: define the cell size a bit smaller than what the path actually covers. The problem is that if the width of the line exceeds 0.5pt, an overshoot by 1pt is no longer sufficient. So one may want to use a more generous overshoot. The following may be a bit "too generous" (but being
                    generous has no real sideeffects here AFAIK), and this one seems to work for many viewers and zoom levels, i.e. some of the things but not all in your code are also viewer issues.



                    documentclass[tikz,border=3.14mm]standalone

                    begindocument

                    begintikzpicture


                    usetikzlibrarypatterns

                    makeatletter
                    tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

                    pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
                    pgfqpoint-hatchthickness-hatchthickness% below left
                    pgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness% above right
                    pgfpointhatchdistancehatchdistance%

                    pgfsetcolortikz@pattern@color
                    pgfsetlinewidthhatchthickness
                    pgfpathmovetopgfqpoint-hatchthickness-hatchthickness
                    pgfpathlinetopgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness
                    pgfusepathstroke

                    pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
                    pgfqpoint-hatchthickness-hatchthickness% below left
                    pgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness% above right
                    pgfpointhatchdistancehatchdistance%

                    pgfsetcolortikz@pattern@color
                    pgfsetlinewidthhatchthickness
                    pgfpathmovetopgfqpointhatchdistance+hatchthickness-hatchthickness
                    pgfpathlinetopgfqpoint-hatchthicknesshatchdistance+hatchthickness
                    pgfusepathstroke

                    makeatother

                    draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
                    draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (2,0) rectangle +(1,1);


                    endtikzpicture
                    enddocument


                    enter image description here






                    share|improve this answer

























                    • When I use your solution I get teeth, even bigger ones, on the other side?!

                      – Pygmalion
                      5 hours ago











                    • @Pygmalion Hmmh, strange. I slightly adjusted the parameters. Is it better now?

                      – marmot
                      2 hours ago
















                    5














                    You do what one usually does: define the cell size a bit smaller than what the path actually covers. The problem is that if the width of the line exceeds 0.5pt, an overshoot by 1pt is no longer sufficient. So one may want to use a more generous overshoot. The following may be a bit "too generous" (but being
                    generous has no real sideeffects here AFAIK), and this one seems to work for many viewers and zoom levels, i.e. some of the things but not all in your code are also viewer issues.



                    documentclass[tikz,border=3.14mm]standalone

                    begindocument

                    begintikzpicture


                    usetikzlibrarypatterns

                    makeatletter
                    tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

                    pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
                    pgfqpoint-hatchthickness-hatchthickness% below left
                    pgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness% above right
                    pgfpointhatchdistancehatchdistance%

                    pgfsetcolortikz@pattern@color
                    pgfsetlinewidthhatchthickness
                    pgfpathmovetopgfqpoint-hatchthickness-hatchthickness
                    pgfpathlinetopgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness
                    pgfusepathstroke

                    pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
                    pgfqpoint-hatchthickness-hatchthickness% below left
                    pgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness% above right
                    pgfpointhatchdistancehatchdistance%

                    pgfsetcolortikz@pattern@color
                    pgfsetlinewidthhatchthickness
                    pgfpathmovetopgfqpointhatchdistance+hatchthickness-hatchthickness
                    pgfpathlinetopgfqpoint-hatchthicknesshatchdistance+hatchthickness
                    pgfusepathstroke

                    makeatother

                    draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
                    draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (2,0) rectangle +(1,1);


                    endtikzpicture
                    enddocument


                    enter image description here






                    share|improve this answer

























                    • When I use your solution I get teeth, even bigger ones, on the other side?!

                      – Pygmalion
                      5 hours ago











                    • @Pygmalion Hmmh, strange. I slightly adjusted the parameters. Is it better now?

                      – marmot
                      2 hours ago














                    5












                    5








                    5







                    You do what one usually does: define the cell size a bit smaller than what the path actually covers. The problem is that if the width of the line exceeds 0.5pt, an overshoot by 1pt is no longer sufficient. So one may want to use a more generous overshoot. The following may be a bit "too generous" (but being
                    generous has no real sideeffects here AFAIK), and this one seems to work for many viewers and zoom levels, i.e. some of the things but not all in your code are also viewer issues.



                    documentclass[tikz,border=3.14mm]standalone

                    begindocument

                    begintikzpicture


                    usetikzlibrarypatterns

                    makeatletter
                    tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

                    pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
                    pgfqpoint-hatchthickness-hatchthickness% below left
                    pgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness% above right
                    pgfpointhatchdistancehatchdistance%

                    pgfsetcolortikz@pattern@color
                    pgfsetlinewidthhatchthickness
                    pgfpathmovetopgfqpoint-hatchthickness-hatchthickness
                    pgfpathlinetopgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness
                    pgfusepathstroke

                    pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
                    pgfqpoint-hatchthickness-hatchthickness% below left
                    pgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness% above right
                    pgfpointhatchdistancehatchdistance%

                    pgfsetcolortikz@pattern@color
                    pgfsetlinewidthhatchthickness
                    pgfpathmovetopgfqpointhatchdistance+hatchthickness-hatchthickness
                    pgfpathlinetopgfqpoint-hatchthicknesshatchdistance+hatchthickness
                    pgfusepathstroke

                    makeatother

                    draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
                    draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (2,0) rectangle +(1,1);


                    endtikzpicture
                    enddocument


                    enter image description here






                    share|improve this answer















                    You do what one usually does: define the cell size a bit smaller than what the path actually covers. The problem is that if the width of the line exceeds 0.5pt, an overshoot by 1pt is no longer sufficient. So one may want to use a more generous overshoot. The following may be a bit "too generous" (but being
                    generous has no real sideeffects here AFAIK), and this one seems to work for many viewers and zoom levels, i.e. some of the things but not all in your code are also viewer issues.



                    documentclass[tikz,border=3.14mm]standalone

                    begindocument

                    begintikzpicture


                    usetikzlibrarypatterns

                    makeatletter
                    tikzsethatch distance/.store in=hatchdistance,hatch distance=5pt,hatch thickness/.store in=hatchthickness,hatch thickness=5pt

                    pgfdeclarepatternformonly[hatchdistance,hatchthickness]north east hatch% name
                    pgfqpoint-hatchthickness-hatchthickness% below left
                    pgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness% above right
                    pgfpointhatchdistancehatchdistance%

                    pgfsetcolortikz@pattern@color
                    pgfsetlinewidthhatchthickness
                    pgfpathmovetopgfqpoint-hatchthickness-hatchthickness
                    pgfpathlinetopgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness
                    pgfusepathstroke

                    pgfdeclarepatternformonly[hatchdistance,hatchthickness]north west hatch% name
                    pgfqpoint-hatchthickness-hatchthickness% below left
                    pgfqpointhatchdistance+hatchthicknesshatchdistance+hatchthickness% above right
                    pgfpointhatchdistancehatchdistance%

                    pgfsetcolortikz@pattern@color
                    pgfsetlinewidthhatchthickness
                    pgfpathmovetopgfqpointhatchdistance+hatchthickness-hatchthickness
                    pgfpathlinetopgfqpoint-hatchthicknesshatchdistance+hatchthickness
                    pgfusepathstroke

                    makeatother

                    draw[pattern=north east hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (0,0) rectangle +(1,1);
                    draw[pattern=north west hatch,hatch distance=7pt,hatch thickness=3pt,pattern color=orange] (2,0) rectangle +(1,1);


                    endtikzpicture
                    enddocument


                    enter image description here







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 2 hours ago

























                    answered 8 hours ago









                    marmotmarmot

                    141k6 gold badges184 silver badges338 bronze badges




                    141k6 gold badges184 silver badges338 bronze badges












                    • When I use your solution I get teeth, even bigger ones, on the other side?!

                      – Pygmalion
                      5 hours ago











                    • @Pygmalion Hmmh, strange. I slightly adjusted the parameters. Is it better now?

                      – marmot
                      2 hours ago


















                    • When I use your solution I get teeth, even bigger ones, on the other side?!

                      – Pygmalion
                      5 hours ago











                    • @Pygmalion Hmmh, strange. I slightly adjusted the parameters. Is it better now?

                      – marmot
                      2 hours ago

















                    When I use your solution I get teeth, even bigger ones, on the other side?!

                    – Pygmalion
                    5 hours ago





                    When I use your solution I get teeth, even bigger ones, on the other side?!

                    – Pygmalion
                    5 hours ago













                    @Pygmalion Hmmh, strange. I slightly adjusted the parameters. Is it better now?

                    – marmot
                    2 hours ago






                    @Pygmalion Hmmh, strange. I slightly adjusted the parameters. Is it better now?

                    – marmot
                    2 hours ago


















                    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%2f498376%2fcreating-patterns%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

                    Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                    Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                    199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單