Graphics, Figures & TablesNon-rotating Coordinate System for Decoration

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

Non-rotating Coordinate System for Decoration

Post by hugovdberg »

I want to draw a number of pictures with lines representing a solid baseline, which in many cases is represented as a thick line with short lines pointing downwards at an angle. I figured out how to do this with a markings, however, since I am a geographer my baselines are rarely straight and the markings are rotated to the tangent of the decorated line. This causes the markings to sometimes point up and sometimes point down, and I would like to have them all parallel. How could I make sure the coordinate system is not rotated?

Also I would like to know where to find a good tutorial for \pgfdeclaredecoration, since I want to use this decoration in more than one figure and don't like copy pasting code if I know that it can be prevented. However, the tikZ manual is not very clear on this topic, and I can't find a good tutorial.

A minimal working example showing the markings problem (pdf output is attached):

Code: Select all

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}
   \draw[thick,postaction={decorate, decoration={
      markings,% switch on markings
      mark=% actually add a mark
        between positions 0 and 1 step 1.5mm
        with
        {
          \draw (0pt,0pt) -- (-3pt,-5pt);
        }
      }}] (0,5) .. controls (0,4) and (1,2.5) .. (5,2) .. controls (7,1.75) and (9,1) .. (9,0);
\end{tikzpicture}
\end{document}
Attachments
tikz_test.pdf
(9.71 KiB) Downloaded 316 times
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

Re: Non-rotating Coordinate System for Decoration

Post by hugovdberg »

I hate bumping topics but I would really like to know how to fix this and if nobody here knows what to do, then where should I ask again?
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

Non-rotating Coordinate System for Decoration

Post by hugovdberg »

Today on TeX.se this question came along, which reminded me of my own question on this forum, and so I decided to dig through this problem once more. Since it is possible to add pins to each decoration, which are set at a constant angle, I started to dig through the code of the TikZ package, and after an hour or three I actually found the command to use, and only by searching for this exact command I could find this in the pgfmanual as well.. The trick is to reset the transformation angle, but not the coordinate translations using \pgftransformresetnontranslations.

Code: Select all

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}[
   decoration={
      markings,% switch on markings
      mark=% actually add a mark
        between positions 0 and 1 step 1.5mm
        with
        {
          \pgftransformresetnontranslations
          \draw (0pt,0pt) -- (240:6pt);
        }
   },
   ]
   \draw[thick,postaction=decorate,] (0,5) .. controls (0,4) and (1,2.5) .. (5,2) .. controls (7,1.75) and (9,1) .. (9,0);
\end{tikzpicture}
\end{document}
decorated.png
decorated.png (3.57 KiB) Viewed 3442 times
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
Post Reply