Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to draw some lines where one of points should be defined like:

($ (A)! \X3 !(B) $)

where \X3 is something from (0,1). But it's not working. Yeah, I could just place the right number, but I'd like use this construction (or quite similar) on several places of this figure and I'd like to make several figures with different \X3.

Any possible way how to set variable into $ $ in TikZ?

share|improve this question
    
you might not want to use numbers in your macros ;) –  percusse Nov 7 '12 at 20:07
add comment

1 Answer

up vote 4 down vote accepted

The proposed syntax works fine. I think the problem is that you have a number in the macro name.

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}


\begin{tikzpicture}
\coordinate (A) at (1,0);
\coordinate (B) at (1,2);

\newcommand*{\X}{0.3}%
\draw [ultra thick, blue, ->] (0,0) -- ($(A)!\X!(B)$);
\end{tikzpicture}
\end{document}
share|improve this answer
    
Thanks a lot, that was defenetly the problem. Now's working. –  Doxxik Nov 7 '12 at 21:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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