Get contour/outline/”halo” around TikZ drawings

tikz-pgf

I have to place symbols and text over a map and in order to get a nice contrast with the background I would like everithing to have a white outline all around.

Here is an example of what I'm looking for. I made it using the "Stroke selection" tool in Photoshop.

Figure 1

I looked around but I wasn't able to find a way to get this effect "automatically" in TikZ. For the text part I found the contour package which works perfectly ((c) in figure below) but for the TikZ drawings I'm still looking for a solution. One thing I tried is to superimpose two versions of the same symbol with different colors and line width ((b) in figure below) but of course this doesn't work because scaling doesn't occour parallel to the lines so there will be no white outline at the endpoints. What happens to the arrow is self explainatory. Other than this I can only think of drawing the outlines manually, which in my case would be feasible but still quite tedious.

enter image description here

Here is the code I used to generate the picuture:

\documentclass[tikz, margin=5mm]{standalone}
\usepackage[outline]{contour}
\contourlength{1pt}

% symbol1
\tikzset{pics/.cd,
            symbol1/.style,
            code={
            % triangle
            \draw (0,0) -- (1,0) -- ({cos(60)}, {sin(60)}) -- (0,0);
            % arrow with text
            \draw[-latex] (-0.2, {sin(60)/3}) node[left]{\Large{1}} -- ({cos(60)},{sin(60)/3});
        }}

\begin{document}
\begin{tikzpicture}
    % background and labels
    \draw[fill=black!10] (-1,-1) rectangle (5,1.5)
                         ({cos(60)}, -0.2) node[below]{(a)}
                         ({2 + cos(60)}, -0.2) node[below]{(b)}
                         (4, -0.2) node[below]{(c)};
    
    % (a) normal instance of symbol1
    \pic[blue,thick] at (0,0) {symbol1};   
    
    % (b) symbol1 superimposed on a white instance of the same symbol with larger line width
    \pic[white,line width=3pt] at (2,0) {symbol1}; 
    \pic[blue, thick] at (2,0) {symbol1};
    
    % (c) text with white outline using contour package
    \draw[blue] (4,{sin(60)/3}) node[]{\contour{white}{\Large{1}}};
\end{tikzpicture}
\end{document}

I'm not a LaTeX nor TikZ expert, so maybe I'm missing something really obvious or maybe that's not possible all together but I still hope someone can give me some hints on how to solve this issue. Also, I'm new on StackExchange, so feel free to tell me if there is any problem with my post (formatting, missing informations, not clear enough, …).

Best Answer

You can simulate an outline by drawing the symbol repeatedly with a shift. (The same way contour does it)

\documentclass[tikz, margin=5mm]{standalone}
% symbol1
\tikzset{pics/.cd,
            symbol1/.style,
            code={
            % triangle
            \draw (0,0) -- (1,0) -- (60:1) -- cycle;
            % arrow with text
            \draw[-latex] (-0.2, {sin(60)/3}) node[left]{\Large{1}} -- ({cos(60)},{sin(60)/3});
        }}

\begin{document}
\begin{tikzpicture}
\draw[fill=black!10] (-1,-1) rectangle (1.5,1.5);
\foreach \ang in {0,10,...,360}
  { \pic[white, thick, shift={(\ang:1pt)}] at (0,0) {symbol1}; };
\pic[blue,thick] at (0,0) {symbol1};   
\end{tikzpicture}
\end{document}

Blue symbol with white outline