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'm just getting warmed to tikz so please forgive me if this is a dumb question I want to declare an newcommand containing a node with text:

\newcommand{\mydoor}[1] {
\draw[black] (1,-1) -- (1,-0) node[right,near start] {{#1}};
}

\begin{tikzpicture}
\mydoor[mytext];
\end{tikzpicture}

The output I get is not "| mytext" but "| ["

What on earth am I missing and how can I design a simple line with a configurable text (I want to use this on a more complicated polygon, therefore the environment)?

share|improve this question
add comment

closed as too localized by egreg, percusse, Marco Daniel, Torbjørn T., Martin Schröder Aug 19 '12 at 12:45

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 2 down vote accepted

The syntax is not right: twice brackets are not necessary in the command definition as the semicolon in the call of the command. Moreover the argument (the text) is mandatory, thus you should use brackets and not square brackets. Try in this way:

\documentclass{article}
\usepackage{tikz}

\newcommand{\mydoor}[1] {
\draw[black] (1,-1) -- (1,-0) node[right,near start] {#1};
}

\begin{document}
\begin{tikzpicture}
\mydoor{mytext}
\end{tikzpicture}
\end{document} 

which gives:

enter image description here

share|improve this answer
    
Many thanks! I was just too stupid too see it ;-) –  Martin May 4 '12 at 12:03
add comment

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