5

Is there any reference of symbols including spinner (any shape) for latex document?

e.g. ;

enter image description here

Shivid
  • 289

3 Answers3

12

The fontawesome package has a command \faSpinner producing this symbol:

enter image description here

You can find it, along with lots of other symbols, in the large symbols-a4.pdf.

Tiuri
  • 7,749
10

Not a very practical solution, but I'm on a vacation and I was bored. :-) I attempted to draw the waiting symbol with TikZ. Here's the result:

waiting

\documentclass{article}
\usepackage{scalerel}
\usepackage{tikz}
\definecolorseries{graygrad}{rgb}{last}{white}{black}
\usetikzlibrary{calc}
\newcommand{\waiting}{%
    \scalerel*{%
    \begin{tikzpicture}
    \coordinate (n-0) at (0,0) {};
    \pgfmathtruncatemacro\maxcount{100}% Change this if necessary, larger numbers for smoother gradient, but longer compiling time.
    \resetcolorseries[\maxcount]{graygrad}%
    \pgfmathsetmacro\stepa{315/\maxcount}% 45deg to -270deg
    \foreach \ii in {0,...,\numexpr\maxcount-1}{%
        \pgfmathtruncatemacro\hi{\ii+1}%
        \draw[draw=graygrad!!\ii, double distance=1cm, line cap=round, double=graygrad!!+] (n-\ii) arc [start angle=45-\ii*\stepa, end angle=45-\hi*\stepa, radius=2.5cm] node (n-\hi) {};
    }
    \end{tikzpicture}%
    }{X}%
}
\begin{document}
    This is my waiting symbol: \waiting\par 
    \Huge This is my waiting symbol \waiting.
\end{document}

In my code, there is a quantity \maxcount which you can change to vary the 'resolution' of the gray gradient in the symbol. At a count of 100, it takes around 2-3 seconds to compile, so it's not very efficient. If the number is too small, then the gradient will appear 'jagged' and not smooth.

Note that I also used the command from the scalerel package to scale the symbol down for in-line use. You can remove it and use a resizebox etc. if you need it at any other size.

Troy
  • 13,741
  • Great job! It is very interesting, I try it soon and if there is any point I will be back to you, so have fun for the rest of your vacation : ) – Shivid May 12 '17 at 14:43
  • Great, thanks :) It's awfully inefficient though (it's all because of the gradient effect...), if you really want to use this, I suggest externalizing it using the tikzexternalize feature. And like I said in my answer, if you only need it as a small icon, you can try reducing \maxcount further so it's not so taxing during compilation. Cheers! – Troy May 12 '17 at 15:01
  • It is efficient indeed and very nice, I implemented it and since I'm using it in a table, the size is just what it should be, so thanks again and probably later I will try it for different documentation with different sizes. Cheers! – Shivid May 12 '17 at 15:17
  • For repeated use, such as in an animation, it is conveniently put into an \xsavebox (pkg of the same name).Then it is typeset only once. – AlexG May 20 '17 at 18:03
  • @AlexG Thanks for the suggestion. I've taken a look at the savebox package documentation, but I can't seem to figure out how to use it in this case. Considering I'm drawing arcs with different start and end angles in each loop, and each arc should have a different colour (consecutive steps in a colour series) – Troy May 21 '17 at 03:03
  • I meant, if using the waiting symbol in an animation, such as in a flip-book, where it is multiply included, xsavebox would accelerate the compilation. But after running tests myself, I found out that the gain of time is not that significant; a standard \savebox would do as well. However, the reduction of PDF file size is worth noting. – AlexG May 22 '17 at 07:50
  • @AlexG Oops I meant to type xsavebox package documentation. In either case, I'm not so sure about how to implement/integrate \savebox/\xsavebox into my code. I'll be agreeable to an addition to my answer, if you would feel so inclined. (since you've already done the tests and all) :) – Troy May 22 '17 at 07:53
  • \xsbox{Waiting}{\waiting}\scalerel*{\theWaiting}{X}\Huge\scalerel*{\theWaiting}{X} saves about 6kB as cmpd to \scalerel*{\waiting}{X}\Huge\scalerel*{\waiting}{X} ;-) . I added a community wiki answer with an animation example. – AlexG May 22 '17 at 08:40
4

The inevitable example of an animated spinner, based on Troy's code (A-Reader or Foxit required). The xsavebox package is used to save some final PDF file size.

\documentclass{article}

\usepackage{tikz}
\definecolorseries{graygrad}{rgb}{last}{white}{black}
\usetikzlibrary{calc}

\usepackage{amssymb}
\usepackage{xsavebox}
\usepackage{scalerel}
\usepackage{animate}

\newcommand{\waiting}{%
    \begin{tikzpicture}
    \coordinate (n-0) at (0,0) {};
    \pgfmathtruncatemacro\maxcount{100}% Change this if necessary, larger numbers for smoother gradient, but longer compiling time.
    \resetcolorseries[\maxcount]{graygrad}%
    \pgfmathsetmacro\stepa{315/\maxcount}% 45deg to -270deg
    \foreach \ii in {0,...,\numexpr\maxcount-1}{%
        \pgfmathtruncatemacro\hi{\ii+1}%
        \draw[draw=graygrad!!\ii, double distance=1cm, line cap=round, double=graygrad!!+] (n-\ii) arc [start angle=45-\ii*\stepa, end angle=45-\hi*\stepa, radius=2.5cm] node (n-\hi) {};
    }
    \end{tikzpicture}%
}

\newlength\myWidth

\begin{document}\Huge
    \xsbox{Waiting}{\waiting}%
    \settowidth\myWidth{\scalerel*{\theWaiting}{X}}%
    %
    This is my waiting symbol:
    \begin{animateinline}[autoplay]{24}
      \multiframe{80}{iAng=0+-15}{
        \hbox to \myWidth{\hss\vbox to \myWidth{\vss\hbox{%
          \rotatebox{\iAng}{\scalerel*{\theWaiting}{X}}%
        }\vss}\hss}
      }
      \newframe
      \hbox to \myWidth{\hss\vbox to \myWidth{\vss\hbox{%
        \huge$\checkmark$%
      }\vss}\hss}
    \end{animateinline}.
\end{document}
AlexG
  • 54,894
  • oh my, i never thought about it this way. it's just a rotation of my drawing isn't it? brilliant. :) – Troy May 22 '17 at 13:23
  • 1
    And it is packed once into a PDF XObject. Only a reference is then rotated. – AlexG May 22 '17 at 14:39
  • Very very interesting, well done! Just I wonder can I use it in a table cell? How can I handle \begin{animateinline} in a table cell? Thank you! – Shivid May 22 '17 at 16:18
  • 1
    Just put the environment where you want it. It behaves like a box (\mbox, \fbox, \usebox, a single letter, ...) – AlexG May 22 '17 at 16:56
  • AlexG, One other thing; after rotation of waiting is finished I'd like to have a word or a number, when I try to put it under \newframe, becomes like a stretched word. Thanks again – Shivid May 23 '17 at 18:48
  • You will have to prescribe the intended word's width to the outer \hbox in the animation. Define another length command, say \myWordWidth, and use \settowidth\myWordWidth{my word} to measure the width. Then use \myWordWidth to set the outer \hbox's width. – AlexG May 24 '17 at 06:40