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 would like to know how to place multiple nodes with same content in TikZ.

I've made a macro for it, but I think that it could have a different approach.

\usepackage{tikz}
\usepackage{bm}
\newcommand{\cross}{%
    node {\LARGE\bm{$\times$}}%
}

\begin{document} 

\begin{tikzpicture}
\draw[black]
    (1,1) \cross
    (3,1) \cross
    (1,4) \cross
    (3,4) \cross;
\end{tikzpicture}

\end{document}

So, my question is: is there any way to do something like this?

\cross{(1,1), (3,1), (1,4), (3,4)}
share|improve this question
    
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. –  Harish Kumar Jan 20 '13 at 1:03
    
Oh, I'm sorry. I'll remember it next time, thanks. –  Gutierrez PS Jan 20 '13 at 1:09
    
@GutierrezPS, you can use a loop: \foreach \p in {(1,1),(3,1),(1,4),(3,4)}{\draw \p node {\LARGE\bm{$\times$}};}. –  Sigur Jan 20 '13 at 1:11
    
Hm, nice approach. But it's more code than I've posted. Is there a way to put this on a macro? I mean, a macro for \cross{(1,1), (3,1), (1,4), (3,4)} with this loop? –  Gutierrez PS Jan 20 '13 at 1:27
1  
Can you write your answer separate from your question? It helps make this site more organized. :-) –  hpesoj626 Jan 20 '13 at 7:36

1 Answer 1

up vote 2 down vote accepted

I've figured out that Sigur's solution was exactly what I wanted (I just needed to put in a macro). So, instead of

\newcommand{\contact}{ node {\LARGE\bm{$\times$}} }

I've used

\newcommand{\contacts}[1]{ %
    \foreach \p in {#1}{\p node {\LARGE\bm{$\times$}}} %
}

In this case, \contacts should be used inside a \draw block:

\draw \contacts((1,1),(5,1),(1,4),(3,1),(5,4));

That produces something like:

enter image description here

share|improve this answer

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.