New answers tagged

5

You can add another guard within the ln and give a safe value (1 here) it doesn't really matter what non-error value you use as it will not affect the result of the outer guard \documentclass{article} \usepackage{tikz} \begin{document} \def\var{0} \pgfmathparse { \var>1 ? ln(\var>1 ? \var:1) : \var}\pgfmathresult \def\var{1} \pgfmathparse { ...


2

calc's macros are not expandable, though PGF expects a mathematical value. PGF does provide its own measurement functions: depth("…"), width("…") and height("…"). The " are needed because they escape the evaluation to text. If you have ,, = or ] in your text, you have to enclose the value in braces. For example: \tikzset{ text vert/.style={ ...


3

This happens because, even though you're setting xmin=-1, xmax=1, the function is still evaluated over a much larger domain (-5:5). The samples outside the axis limits are just not displayed. This creates a lot of unnecessary overhead, so you should limit the domain by setting domain=-1:1: \documentclass{standalone} \usepackage{tikz} ...


2

Use \pgfmathsetmacro instead of \pgfmathtruncatemacro. From section 89.1 Commands for Parsing Expressions of the PGF manual (two or three lines above the \pgfmathtruncatemacro) \pgfmathsetmacro{hmacroi}{hexpressioni} Defines hmacroi as the value of hexpressioni. The result is a decimal without units. \pgfmathtruncatemacro{hmacroi}{hexpressioni} ...



Top 50 recent answers are included