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 want to add styles to my nodes that draw additional paths inside of the node.

For example (without proper placement of nodes)

\node[draw,circle,lVert] {};
\node[draw,circle,lHor]  {};
\node[draw,circle,lVert,lHor] {};

shall result in these nodes:

enter image description here

Keywords

strike through node, line in node, strike through style, cross, path as style

share|improve this question
1  
Seems similar to Creating a seamless XOR symbol as node. –  Claudio Fiandrino Feb 13 at 15:10
    
@ClaudioFiandrino There is a solution to my problem slumbering in the accepted answer to that question. –  ziggystar Feb 13 at 15:15

2 Answers 2

Adapting the solution of the following question (thanks to Claudio's comment): Creating a seamless XOR symbol as node

I ended up with this working and extremely simple code:

\begin{tikzpicture}[
    every node/.style={draw,circle},
    hVert/.style={append after command={(\tikzlastnode.north) edge (\tikzlastnode.south)}},
    hHorz/.style={append after command={(\tikzlastnode.west) edge (\tikzlastnode.east)}}
  ]
  \node[hVert] (a) {};
  \node[right=of a,hVert,hHorz] (f) {};
  \node[right=of f,hHorz] (b) {};
\end{tikzpicture}
share|improve this answer

Another option: declare three new shapes.

It would be better to declare only one new shape with some parameter to draw horizontal, vertical or both lines, but I don't know how to do it.

\documentclass[tikz, border=2mm]{standalone}

\makeatletter
\pgfdeclareshape{hVert}
{
  \inheritsavedanchors[from=circle] % this is nearly a circle
  \inheritanchorborder[from=circle]
  \inheritanchor[from=circle]{north}
  \inheritanchor[from=circle]{north west}
  \inheritanchor[from=circle]{north east}
  \inheritanchor[from=circle]{center}
  \inheritanchor[from=circle]{west}
  \inheritanchor[from=circle]{east}
  \inheritanchor[from=circle]{mid}
  \inheritanchor[from=circle]{mid west}
  \inheritanchor[from=circle]{mid east}
  \inheritanchor[from=circle]{base}
  \inheritanchor[from=circle]{base west}
  \inheritanchor[from=circle]{base east}
  \inheritanchor[from=circle]{south}
  \inheritanchor[from=circle]{south west}
  \inheritanchor[from=circle]{south east}
  \inheritbackgroundpath[from=circle]
  \foregroundpath{
    \centerpoint% 
    \pgf@xc=\pgf@x% 
    \pgf@yc=\pgf@y%
    \pgfutil@tempdima=\radius%
    \advance\pgfutil@tempdima by -.5\pgflinewidth%
    \pgfpathmoveto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{0pt}{\pgfutil@tempdima}}}
    \pgfpathlineto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{0pt}{-\pgfutil@tempdima}}}
    \pgfsetarrowsstart{}
    \pgfsetarrowsend{}
  }
}
\pgfdeclareshape{hHorz}
{
  \inheritsavedanchors[from=circle] % this is nearly a circle
  \inheritanchorborder[from=circle]
  \inheritanchor[from=circle]{north}
  \inheritanchor[from=circle]{north west}
  \inheritanchor[from=circle]{north east}
  \inheritanchor[from=circle]{center}
  \inheritanchor[from=circle]{west}
  \inheritanchor[from=circle]{east}
  \inheritanchor[from=circle]{mid}
  \inheritanchor[from=circle]{mid west}
  \inheritanchor[from=circle]{mid east}
  \inheritanchor[from=circle]{base}
  \inheritanchor[from=circle]{base west}
  \inheritanchor[from=circle]{base east}
  \inheritanchor[from=circle]{south}
  \inheritanchor[from=circle]{south west}
  \inheritanchor[from=circle]{south east}
  \inheritbackgroundpath[from=circle]
  \foregroundpath{
    \centerpoint% 
    \pgf@xc=\pgf@x% 
    \pgf@yc=\pgf@y%
    \pgfutil@tempdima=\radius%
    \advance\pgfutil@tempdima by -.5\pgflinewidth%
    \pgfpathmoveto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{\pgfutil@tempdima}{0pt}}}
    \pgfpathlineto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{-\pgfutil@tempdima}{0pt}}}
    \pgfsetarrowsstart{}
    \pgfsetarrowsend{}
  }
}
\pgfdeclareshape{hVertHorz}
{
  \inheritsavedanchors[from=circle] % this is nearly a circle
  \inheritanchorborder[from=circle]
  \inheritanchor[from=circle]{north}
  \inheritanchor[from=circle]{north west}
  \inheritanchor[from=circle]{north east}
  \inheritanchor[from=circle]{center}
  \inheritanchor[from=circle]{west}
  \inheritanchor[from=circle]{east}
  \inheritanchor[from=circle]{mid}
  \inheritanchor[from=circle]{mid west}
  \inheritanchor[from=circle]{mid east}
  \inheritanchor[from=circle]{base}
  \inheritanchor[from=circle]{base west}
  \inheritanchor[from=circle]{base east}
  \inheritanchor[from=circle]{south}
  \inheritanchor[from=circle]{south west}
  \inheritanchor[from=circle]{south east}
  \inheritbackgroundpath[from=circle]
  \foregroundpath{
    \centerpoint% 
    \pgf@xc=\pgf@x% 
    \pgf@yc=\pgf@y%
    \pgfutil@tempdima=\radius%
    \advance\pgfutil@tempdima by -.5\pgflinewidth%
    \pgfpathmoveto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{0pt}{\pgfutil@tempdima}}}
    \pgfpathlineto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{0pt}{-\pgfutil@tempdima}}}
    \pgfpathmoveto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{\pgfutil@tempdima}{0pt}}}
    \pgfpathlineto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{-\pgfutil@tempdima}{0pt}}}
    \pgfsetarrowsstart{}
    \pgfsetarrowsend{}
  }
}
\makeatother

\begin{document}
\begin{tikzpicture}
\node[hHorz,draw, thick, blue, fill=red!30] (A) at (0,0) {};
\node[hVert,draw, red, fill=blue!30, minimum size=.75cm] (B) at (1,1) {};
\node[hVertHorz,draw, thick,fill=red!30!blue] (C) at (2,0) {};
\draw (A)--(B)--(C);
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
I thought about this. But I'm going to require even more decorations and the number of shapes would grow exponentially. Also I need to decorate both circles and squares. But maybe this solution serves someone else. –  ziggystar Feb 13 at 19:00

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.