1

Lately, I have been using the baseline argument in TikZ pictures, but I couldn't figure out what was the default unit of length. I know that the cm is the default unit for TikZ package, but it doesn't seem to be se case for baseline :

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}

\begin{document}

without baseline :
    \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45]
        \clip(-1,-1) rectangle (5,5);
        \draw [line width=1pt] (0,4)-- (4,4);
        \draw [line width=1pt] (4,4)-- (4,0);
        \draw [line width=1pt] (4,0)-- (0,0);
        \draw [line width=1pt] (0,0)-- (0,4);
    \end{tikzpicture}\\
with baseline (no unit) :
    \begin{tikzpicture}[baseline=2, line cap=round,line join=round,>=triangle 45]
        \clip(-1,-1) rectangle (5,5);
        \draw [line width=1pt] (0,4)-- (4,4);
        \draw [line width=1pt] (4,4)-- (4,0);
        \draw [line width=1pt] (4,0)-- (0,0);
        \draw [line width=1pt] (0,0)-- (0,4);
    \end{tikzpicture}\\
with baseline (cm) :
    \begin{tikzpicture}[baseline=2cm, line cap=round,line join=round,>=triangle 45]
        \clip(-1,-1) rectangle (5,5);
        \draw [line width=1pt] (0,4)-- (4,4);
        \draw [line width=1pt] (4,4)-- (4,0);
        \draw [line width=1pt] (4,0)-- (0,0);
        \draw [line width=1pt] (0,0)-- (0,4);
    \end{tikzpicture}
\end{document}

Does any one have any idea about where I could find this kind of information.

Best regards

5
  • 3
    Coordinates may default to 1cm (see \pgfsetxvec and \pgfsetyvec), but arguments default to pt, same as normal LaTeX (except without the error message). – John Kormylo Mar 27 '18 at 17:56
  • Yes, this is perhaps one of the most confusing aspects of TikZ/pgf. It also expects the arguments of sin and cos to be in degrees whereas the arguments of sinh and cosh are not. – user121799 Mar 27 '18 at 18:24
  • @marmot but sinh and cosh are not really trigonometric function unlike sin and cos. For the former an argument of degree seems really odd. – Skillmon Mar 27 '18 at 21:56
  • @Skillmon No, I certainly wouldn't want any function to have arguments in degrees. – user121799 Mar 27 '18 at 21:58
  • @marmot me neither, but it is at least reasonable that sinh and cosh don't take their arguments in degrees while it is somewhat understandable that sin and cos do. – Skillmon Mar 28 '18 at 6:47
3

It seems that this is interpreted in pt:

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}

\begin{document}

without baseline :
    \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45]
        \clip(-1,-1) rectangle (5,5);
        \draw [line width=1pt] (0,4)-- (4,4);
        \draw [line width=1pt] (4,4)-- (4,0);
        \draw [line width=1pt] (4,0)-- (0,0);
        \draw [line width=1pt] (0,0)-- (0,4);
    \end{tikzpicture}\\
with baseline (no unit) :
    \begin{tikzpicture}[baseline=2, line cap=round,line join=round,>=triangle 45]
        \clip(-1,-1) rectangle (5,5);
        \draw [line width=1pt] (0,4)-- (4,4);
        \draw [line width=1pt] (4,4)-- (4,0);
        \draw [line width=1pt] (4,0)-- (0,0);
        \draw [line width=1pt] (0,0)-- (0,4);
    \end{tikzpicture}\\
with baseline (pt) :
    \begin{tikzpicture}[baseline=2pt, line cap=round,line join=round,>=triangle 45]
        \clip(-1,-1) rectangle (5,5);
        \draw [line width=1pt] (0,4)-- (4,4);
        \draw [line width=1pt] (4,4)-- (4,0);
        \draw [line width=1pt] (4,0)-- (0,0);
        \draw [line width=1pt] (0,0)-- (0,4);
    \end{tikzpicture}
\end{document}

gives identic results.

4
  • 1
    I also noticed that. But couldn't find anything to confirm it. – IdoDaisuke Mar 27 '18 at 17:50
  • @IdoDaisuke I think it is not mentioned in the pgfmanual. At least not on the first 128 pages... – Skillmon Mar 29 '18 at 18:15
  • @IdoDaisuke page 132 mentions something related, I guess: If two numbers, one with a dimension and one without, are summed up, the dimensionless is considered pt. – Skillmon Mar 29 '18 at 19:05
  • @IdoDaisuke the only other information about interpreting something as pt I found is: "The dimensionless units of SVG are always interpreted as points (pt)." on page 744. – Skillmon Mar 29 '18 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.