16

I am looking for a "Shield" symbol:

enter image description here

I already perused the Comprehensive Latex Symbol List, with the closest fit being \dsheraldical from the dictsym package, which is however non-satisfactory because of the diagonal bar - I need both the symbol itself and a strike-through version of the symbol, and that doesn't look good with \dsheraldical.

I also tried Detexify, but either my drawing skills suck or such a symbol simply doesn't exist.

Any suggestions - either for where to find that symbol, or how to "create" it through other ways?

EDIT: Building on Jake's answer, my solution looks like this:

\usepackage{tikz}

% Smaller than Jake's version, which was much larger than other symbols
\newcommand\shield{ \tikz [baseline] \draw (0,1.5ex) -- (0,0.75ex) arc [radius=0.5ex, start angle=-180, end angle=0] -- (1ex,1.5ex) -- cycle; }
% Strikethrough version of the same symbol
\newcommand\struckshield{ \tikz [baseline] \draw (0,1.5ex) -- (0,0.75ex) arc [radius=0.5ex, start angle=-180, end angle=0] -- (1ex,1.5ex) -- cycle (0,0) -- (1.0ex,1.75ex); }

Look, Ma, I can do TikZ! :-)

DevSolar
  • 7,857

4 Answers4

22

You could, of course, use TikZ for this:

The symbol will scale with your font size, since it uses ex to define the path.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\newcommand\shield{%
    \tikz [baseline] \draw (0,1.75ex) -- (0,0.75ex) arc [radius=0.75ex, start angle=-180, end angle=0] -- (1.5ex,1.75ex) -- cycle;%
}

A shield: \shield
\end{document} 

If you're feeling fancy, you could parametrise it a bit:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\begin{document}
\newcommand\shield[1][]{%
\tikzset{
    shield width/.store in=\shieldwidth,
    shield width=1.5ex,
    shield height/.store in=\shieldheight,
    shield height=1.75ex
}%
\tikz [baseline,#1] \draw (0,\shieldheight) -- (0,\shieldwidth/2) arc [radius=\shieldwidth/2, start angle=-180, end angle=0] -- (\shieldwidth,\shieldheight) -- cycle;%
}

A shield: \shield

A wide shield: \shield[shield width=2ex]

A tall shield: \shield[shield height=3ex]
\end{document} 
Jake
  • 232,450
  • 2
    You could make a new box for the shield, save the tikz shield inside that, and define a new command \shield which just copies that box. I guess it'd be a bit lighter that way if the shield is used frequently. – morbusg Dec 19 '11 at 08:50
  • @morbusg: That sounds like a good idea, but I've never done anything with boxes. Would you care to add a new answer or edit this one to show how to do that? – Jake Dec 19 '11 at 08:54
  • 1
    Jake, @morbusg: Also check out my storebox package which takes care that such repeated content is only stored once in the output PDF. However, for a small drawing like this it might not be that important. – Martin Scharrer Dec 19 '11 at 09:06
  • 2
    It could just be something like: \newbox\shieldbox\setbox\shieldbox=\hbox{\tikz\draw<...>}\def\shield{\copy\shieldbox} and after that one could use it with \shield. – morbusg Dec 19 '11 at 09:50
  • 1
    You should use \usebox instead of \copy to make sure horizontal mode is entered first. – Martin Scharrer Dec 19 '11 at 09:54
  • Oh, nevermind about the new box, it couldn't scale with the font size. – morbusg Dec 19 '11 at 09:54
  • @MartinScharrer: yeah or prefix with \leavevmode – morbusg Dec 19 '11 at 09:56
  • @morbusg: You could add a \resizebox or \scalebox with a font size dependent factor. – Martin Scharrer Dec 19 '11 at 10:02
  • Very, very nice and helpful answer. But I actually prefer Count Zero's solution, since it doesn't require TikZ plus a macro. – DevSolar Dec 19 '11 at 10:33
  • @DevSolar: Agreed, Count Zero's solution is definitely the way to go for this. – Jake Dec 19 '11 at 11:05
  • @Jake: As per comment to Count Zero, while his solution has a certain appeal, milstd gave me trouble... since I am completely new to TikZ, would you mind showing me how to create a strikethrough-version of the shield? (Horizontal line would be nice, diagonal bottom-left-to-top-right would be perfect.) – DevSolar Dec 19 '11 at 12:41
  • @Jake: Nevermind, I figured it out. – DevSolar Dec 19 '11 at 13:45
15

There is another way to do that: in the milstd package there is a symbol (in fact a rotated logical AND gate), which in fact has a completely different signification, but looks like what you need: \ANDd:

enter image description here

Torbjørn T.
  • 206,688
Count Zero
  • 17,424
  • Ah, nice, that's the way to go. How did you find that? – Jake Dec 19 '11 at 09:43
  • 2
    @Jake: Got good visual memory. ;) – Count Zero Dec 19 '11 at 09:45
  • Bwahahaha... VERY nice. Wouldn't have thought of that. :-D – DevSolar Dec 19 '11 at 10:32
  • Putting this to the test uncovered some problems with the (apparently ancient) milstd package, while the more complex TikZ answer worked out of the box... sorry but while I very much like your solution, the checkmark of approval goes to the answer that actually floats my boat. ;-) – DevSolar Dec 19 '11 at 12:31
  • 3
    For the record: It's this milstd package by Rick Simpson, not the other milstd package by Kent McPherson which I tried first and failed :-) – diabonas Dec 19 '11 at 12:53
  • Hm... could still use installation instructions. I fail miserably at getting it installed. TeXLive doesn't have it, manual install fails to work so far. Best I got is "Font \milstd=milstd not loadable: metric data not found or bad."... – DevSolar Dec 19 '11 at 13:07
  • @DevSolar Download the package and extract it into a folder where TeX can find it (e. g. put the three files milstd.mf/.sty/.tex in your working directory). Afterwards, you can use it like this: \documentclass{article} \usepackage{milstd} \begin{document} \ANDd \end{document} – diabonas Dec 19 '11 at 16:55
  • 1
    @diabonas: Thanks' I wasn't aware there were two of them... I added the link to my answer, hope it's ok. :) – Count Zero Dec 19 '11 at 21:36
  • @diabonas: I use TeXLive on both Linux and Windows. Putting into working directory doesn't work ("milstd.sty not found"). Putting into texmf-local/tex/latex and calling texhash doesn't work ("Font \milstd=milstd not loadable: metric data not found or bad."). – DevSolar Dec 20 '11 at 06:08
3

I need a shield symbol and Jake's answer inspired me. I share my tikz code for my shield shield here:

\documentclass[11pt]{article} 
\usepackage{tikz,pifont}

\newcommand\shield{
\tikz [baseline] \draw (3ex,2.5ex) -- (1.5ex,3ex) -- (0ex,2.5ex)  to [out=-90, in=165] (1.5ex,0ex) to [out=15, in=-90] cycle (1.5ex,1.5ex) node {\ding{51}};}

\begin{document}

\shield

\end{document}
Tan
  • 61
2

For the record, a tikz-free solution using the \fontawesome5 icon package, \faShield* command.

enter image description here

BambOo
  • 8,801
  • 2
  • 20
  • 47