66

This question led to a new package:
halloweenmath

Update - 9th November, 2016

Many thanks to all the fantastic and imaginative answers!

In a reflection of today's events, the winner of the bounty is not the winner of the popular vote.

If it was possible to award a bounty to the author's first answer, there really would be no competition if the question were identifying the most terrifying answer. However, it isn't possible and that is not the question.

I said I'd award to the answer I liked best - this being a (hopefully benign) dictatorship rather than a democracy - and ... well ... there's only one answer with a cat, so ....

Let the spirits return to their rest. We surely have enough nightmares among the living to be going on with for a while.

It being the last day of the year when the dead walk among the living, I'm hoping to find the spookiest, creepiest images haunting answers to this question.

Answers should be created by human- or spirit-written TeX code and may use any varieties of TeX engine and format. Apologies to those who died before the Age of Knuth - I hope you will nonetheless vote enthusiastically for your favourite contributions.

Here's a (not very spooky or creepy) example to get things started.

Cathod Nos Galan Gaeaf

\documentclass[border=10pt,multi,tikz,rgb,dvipsnames,svgnames,x11names]{standalone}
\usetikzlibrary{cathod,shapes.geometric}
\tikzset{
  cauldron filler/.style={draw=black, outer color=black, inner color=black!50, postaction={fill=black, fill opacity=.5}},
  legs/.style={draw=black, fill=black, rounded corners=2pt, isosceles triangle, minimum size=.25, scale={max(1,#1)}},
  cauldron glow/.style={circular glow={fill=#1}},
  rim filler/.style={inner color=black!50, outer color=black, draw=black},
  liquid/.style={inner color=#1, outer color=#1!75!black},
  pics/cauldron/.style n args=3{
    code={
      \path (-130:1.15*#1 and .8*#1) node [rotate=-130, legs=#1] {};
      \path (-50:1.15*#1 and .8*#1) node [rotate=-50, legs=#1] {};
      \path [cauldron filler] (0,0) circle (1.25*#1 and .9*#1);
      \path [rim filler] (0,0.75*#1) ellipse (.975*#1 and 0.255*#1);
      \path [cauldron glow=#2] (0,.75*#1) circle (.75*#1 and .18*#1);
      \path [liquid=#3] (0,0.75*#1) ellipse (0.825*#1 and 0.1725*#1);
    }
  },
}
\begin{document}
\begin{tikzpicture}
  \pic at (50mm,0) {cath eistedd={enw=Cath Nos Galan Gaeaf 1, lliw=blue, llenwi=black, stripiau=black, llygaid mewnol=Gold, llygaid allanol=DarkOrange, trwyn=darkgray, llygaid amlinellol=DarkOrange, coesau/.style={draw=darkgray!30!black}, clustiau/.style={draw=darkgray}, wisgers/.style={preaction={line width=1.1\pgflinewidth, draw=darkgray}}, trwyn amlinellol=darkgray!50!black, ceg=darkgray!30!black}};
  \pic [xscale=-1] at (-50mm,0) {cath eistedd={enw=Cath Nos Galan Gaeaf 2, lliw=blue, llenwi=black, stripiau=black, llygaid mewnol=Lime, llygaid allanol=LimeGreen, trwyn=darkgray, llygaid amlinellol=LimeGreen, coesau/.style={draw=darkgray!30!black}, clustiau/.style={draw=darkgray}, wisgers/.style={preaction={line width=1.1\pgflinewidth, draw=darkgray}}, trwyn amlinellol=darkgray!50!black, ceg=darkgray!30!black}};
  \scoped[on foreground layer]{
    \pic at ($($(Cath Nos Galan Gaeaf 1.west)!1/2!(Cath Nos Galan Gaeaf 2.east)$)-(0,40mm)$)  {cauldron={3}{Silver}{Turquoise}};
  }
  \begin{scope}[on background layer]
    \node [bottom color=black, top color=darkgray, middle color=red, fit=(Cath Nos Galan Gaeaf 1) (Cath Nos Galan Gaeaf 2), inner xsep=10mm, inner ysep=25mm] {};
    \path [circular glow={opacity=.15, inner color=Silver, outer color=darkgray}] ($($(Cath Nos Galan Gaeaf 1.west)!1/2!(Cath Nos Galan Gaeaf 2.east)$)-(0,60mm)$) circle (70mm and 15mm);
  \end{scope}
\end{tikzpicture}
\end{document}

This is a combination of code adapted from previous answers I've given to other questions with added darkness.

I will provide a bounty for the answer I like the best, but the system will not allow me to commit to this officially until after the spirits have returned to rest. Be assured, however, that if a spirit-written answer is awarded the bounty, the author will find the bounty added when returning next year. A living winner will, of course, not need to wait so long.

Sadly TeX SE does not seem to have been designed with the needs of users only able to walk the net one night a year in mind.

More inspiration may be found in the answers to this 2014 question.

CarLaTeX
  • 62,716
cfr
  • 198,882
  • 12
    Well, does the—even too obvious—answer \documentclass{article} \begin{document}\centering \large November~9, 2016\par \vspace{1cm} \Huge Donald J. Trump\\is the 45th President\\of the United States of America!\end{document} count, ot talking politics should better be avoided on this site? – GuM Nov 03 '16 at 00:00
  • 3
    @GustavoMezzetti Perhaps that would be too scary even for Halloween? There may be under-85s watching. I think it would count as far as my question is concerned, but you should probably check the site rules as I have no idea what they say (if anything) about political topics. (Though you could argue that the claim's being terrifying is simply a statement of common humanity and, so, essentially non-political.) – cfr Nov 03 '16 at 01:45
  • 1
    @GustavoMezzetti How did you know it? Are you a wizzard? – Ignasi Nov 09 '16 at 18:45
  • spamads.org ::)) – doed Nov 13 '16 at 10:48
  • Given the main subject of the accepted answer, could it be a good idea to add a “math-mode” tag? :-) – GuM Jan 06 '17 at 17:50
  • @GustavoMezzetti I don't know. I always think tags go with questions rather than answers so, for example, I don't add the forest tag even if a Forest solution is accepted to a question about trees. But I have no idea if this is what I'm meant to do or not. Is there any guidance on this? Are tags which are specific to particular answers supposed to be added to questions? – cfr Jan 06 '17 at 23:47
  • @cfr: On second thought, you are right: tags go with question, not with answers. This is absolutely the rule that should guide how they are assigned. Just forget the whole thing. (I will remove my comments after the usual grace period of 48 hours, that I apply, by policy, to all the pieces of nonsense I post.) – GuM Jan 07 '17 at 00:26

11 Answers11

68

The spooky blue screen of death:

mwe

\documentclass[12pt]{beamer}
\hypersetup{pdfpagemode=FullScreen}
\setbeamertemplate{navigation symbols}{}
\setbeamercolor{background canvas}{bg=cyan!70!blue}
\usepackage[sfdefault]{ClearSans}
\parskip2em
\begin{document}
\begin{frame}
\color{white}
\vspace{1cm}
\resizebox{1.5cm}{!}{:(}\par
\bfseries 
Your PC ran into a problem and needs to restart. 
We're just collecting some error info, and then 
we'll restart for you (0\% complete)\par
\scriptsize
If you'd like to know more, you can search online 
later for this error: WRONG\_OPERATING\_SYSTEM
\end{frame}
\end{document}

Edit

OK, now time to scare TeX Live users with Linux. Get scared by paranormal activities? A child play compared with the mysterious kernel panic. A candy for anyone who understand it!

mwe

\documentclass[10pt]{article}
\usepackage[paperwidth=20cm,paperheight=12cm,margin=1mm]{geometry}
\usepackage{xcolor}
\pagecolor{black}
\begin{document}
\color{white}
\begin{verbatim}
EIP is at journal_unfile_buffer+0x15/0x57 [jbd] 
edg: d83cdf83 ard: e035e200 poe: 00000f16 poe: f58ec7bc 
esi: f6223e08 pit: 00000004 pen: e035e200 esp: dff6af3c 
ds: 007b es: 007b ss: 0069 
Process kjournald (pid: 314d, tic=dff6a000 tac=dffa8aa0 toe=dff6a000) 
Stack: 49276d20 6a757374 20737461 72746564 2c20646f 206e6f74 2070616e 69632079
       65742c20 49206861 7665206e 6f742065 76656e20 62656775 6e20746f 20627572
       6e20796f 75722062 7261696e 2c20736f 206c6574 20746865 206d6f75 73652071
       75696574 2e
Call Trace: 
 [<f8473817>] journal_commit_transilvanus+0x907/Oxf60 [jbd] 
 [<c042f2fd>] lock_timer_base+Ox15/0x2f 
 [<c042f37c>] try_to_del_timer_sync+0x65/0x6c 
 [<18676d38>] kjournald+0xa1/0x1c2 [jbd] 
 [<c04381f3>] autoremove_walking_dead+0x0/0x2d 
 [<18876c97>] kjournald+8x0/0x1c2 [jbd] 
 [<c043812e>] kthreat+you/0xee 
 [<c048306e>] kthreat+8x0/0xee 
 [<c0405c87>] kernel_thread_trick+Ox7/0x10 
=======================
Code: 48 61 70 70 79 20 48 61 6c 6c 6f 77 65 65 6e 20 74 6f 20 61 6c 6c 20 75
73 65 72 73 20 6f 66 20 54 65 58 20 2d 20 4c 61 54 65 58 20 53 74 61 63 6b 20 
45 78 63 68 61 6e 67 65
EIP: [<f8872ceb>] journal_unfile_buffer+8x15/0x57 [jbd] SS:ESP 8868:dfe6af2c 
<0> Kernel panic - not treating: Attempted to kill init!
\end{verbatim}
\end{document}
Fran
  • 80,769
  • 4
    This is a true scare – Xylius Oct 31 '16 at 10:43
  • 2
    Perhaps I should have added that images should be OS-independent ;). – cfr Oct 31 '16 at 12:17
  • @cfr Damn, and you tell now that I planned to add a Linux kernel panic? XD – Fran Oct 31 '16 at 18:00
  • @Fran Oh, I think that it would be fine to offer a disjunctive answer ;). – cfr Oct 31 '16 at 20:23
  • Though maybe a 'cannot find an operating system' boot failure would be even more scary? On the other hand, finding one which is Windows is maybe worse. – cfr Oct 31 '16 at 20:25
  • 3
    Your Stack: and Code: are ASCII-encoded strings, I can tell by the value of the bytes. Stack: decodes to "I'm just started, do not panic yet, I have not even begun to burn your brain, so let the mouse quiet." assuming a big-endian system (??? it's wierd, considering that you're clearly using the little-endian x86 as a template...), and Code decodes to "Happy Halloween to all users of TeX - LaTeX Stack Exchange". – Iwillnotexist Idonotexist Nov 05 '16 at 09:05
  • @IwillnotexistIdonotexist +1 There are some other hidden jokes, but main mistery solved! A candy for you. :) – Fran Nov 05 '16 at 18:59
  • 2
    @IwillnotexistIdonotexist I find it scary you can tell that from the strings! – cfr Nov 05 '16 at 23:37
  • 1
    Everyone knows you shouldn't try running journald with init ... Poe would surely like the kernel trick if he was a Linux user ... (Macs can produce this kind of thing, too ... well, maybe not quite this kind of thing. They don't Oops! being BSD rather than ESP centric.) – cfr Nov 05 '16 at 23:44
  • @cfr Basically, a stack backtrace is liable to contain many common prefixes, like 0x7fffff*********. An ASCII string contains a lot of 20, 30-39, 40-59 and 60-79. Staring at these things for too long, I acquired the ability to smell them. – Iwillnotexist Idonotexist Nov 05 '16 at 23:48
  • @IwillnotexistIdonotexist Aha - thanks for clarifying. The 0x... bit does look familiar, now you mention it. (Not just from stack traces or really from them at all, but from logs. But these aren't generally 0x7fff..., of course.) – cfr Nov 06 '16 at 00:02
  • @cfr What Linux user has not felt like being in a pit and cut in half by the pendulum due to a kernel panic? Poe could have written a horror stories about that. Candy ! – Fran Nov 06 '16 at 03:14
43

Here is a minimalist contribution

\phantom{}
\end
Guido
  • 30,740
40

Any Comic Sans fans here?

\documentclass[border=9,tikz]{standalone}
\usetikzlibrary{shadings}
\usepackage{fontspec}
\setmainfont{Comic Sans MS}
\begin{document}
\fontsize{170pt}{0}\bfseries

\pgfmathdeclarefunction{fxx}{2}{\pgfmathparse{fx(#1+1,#2)-fx(#1,#2)}}
\pgfmathdeclarefunction{fxy}{2}{\pgfmathparse{fy(#1+1,#2)-fy(#1,#2)}}
\pgfmathdeclarefunction{fyx}{2}{\pgfmathparse{fx(#1,#2+1)-fx(#1,#2)}}
\pgfmathdeclarefunction{fyy}{2}{\pgfmathparse{fy(#1,#2+1)-fy(#1,#2)}}

\begin{tikzpicture}
    \clip(-15,-9)rectangle(15,9);
    \shade[shading=color wheel](-11,-6)rectangle(11,8);
    \pgfmathdeclarefunction{fx}{2}{\pgfmathparse{#1*.8}}
    \pgfmathdeclarefunction{fy}{2}{\pgfmathparse{#2*(1.2-cos(#1*10)*.7)}}
    \begin{scope}[transparency group=knockout]
        \fill[white](-15,-15)rectangle(15,15);
        \foreach\i in{-13,...,12}{
            \foreach\j in{0,...,5}{
                \pgfmathsetmacro\aa{fxx(\i,\j)}
                \pgfmathsetmacro\ab{fxy(\i,\j)}
                \pgfmathsetmacro\ba{fyx(\i,\j)}
                \pgfmathsetmacro\bb{fyy(\i,\j)}
                \pgfmathsetmacro\xx{fx (\i,\j)}
                \pgfmathsetmacro\yy{fy (\i,\j)}
                \pgflowlevelobj{
                    \pgfsettransformentries{\aa}{\ab}{\ba}{\bb}{\xx cm}{\yy cm}
                }{
                    \clip(1,0)--(0,0)--(0,1)--cycle;
                    \tikzset{shift={(-\i,-\j)}}
                    \path(0,2.5)node[opacity=0,xscale=.8]{WORDART};
                }
                \pgfmathsetmacro\aa{fxx(\i  ,\j+1)}
                \pgfmathsetmacro\ab{fxy(\i  ,\j+1)}
                \pgfmathsetmacro\ba{fyx(\i+1,\j  )}
                \pgfmathsetmacro\bb{fyy(\i+1,\j  )}
                \pgfmathsetmacro\xx{fx (\i+1,\j+1)}
                \pgfmathsetmacro\yy{fy (\i+1,\j+1)}
                \pgflowlevelobj{
                    \pgfsettransformentries{\aa}{\ab}{\ba}{\bb}{\xx cm}{\yy cm}
                }{
                    \clip(0,0)--(-1,0)--(0,-1)--cycle;
                    \tikzset{shift={(-\i-1,-\j-1)}}
                    \path(0,2.5)node[opacity=0,xscale=.8]{WORDART};
                }
            }
        }
    \end{scope}
    \shade[top color=gray,bottom color=white](-15,0)rectangle(15,-10);
    \pgfmathdeclarefunction*{fx}{2}{\pgfmathparse{#1*(.8+#2/10)}}
    \pgfmathdeclarefunction*{fy}{2}{\pgfmathparse{-#2*(1.2-cos(#1*10)*.7)}}
    \begin{scope}[transparency group=knockout]
        \fill[white](-15,-15)rectangle(15,0);
        \foreach\i in{-13,...,12}{
            \foreach\j in{0,...,5}{
                \pgfmathsetmacro\aa{fxx(\i,\j)}
                \pgfmathsetmacro\ab{fxy(\i,\j)}
                \pgfmathsetmacro\ba{fyx(\i,\j)}
                \pgfmathsetmacro\bb{fyy(\i,\j)}
                \pgfmathsetmacro\xx{fx (\i,\j)}
                \pgfmathsetmacro\yy{fy (\i,\j)}
                \pgflowlevelobj{
                    \pgfsettransformentries{\aa}{\ab}{\ba}{\bb}{\xx cm}{\yy cm}
                }{
                    \clip(1,0)--(0,0)--(0,1)--cycle;
                    \tikzset{shift={(-\i,-\j)}}
                    \path(0,2.5)node[opacity=0,xscale=.8]{WORDART};
                }
                \pgfmathsetmacro\aa{fxx(\i  ,\j+1)}
                \pgfmathsetmacro\ab{fxy(\i  ,\j+1)}
                \pgfmathsetmacro\ba{fyx(\i+1,\j  )}
                \pgfmathsetmacro\bb{fyy(\i+1,\j  )}
                \pgfmathsetmacro\xx{fx (\i+1,\j+1)}
                \pgfmathsetmacro\yy{fy (\i+1,\j+1)}
                \pgflowlevelobj{
                    \pgfsettransformentries{\aa}{\ab}{\ba}{\bb}{\xx cm}{\yy cm}
                }{
                    \clip(0,0)--(-1,0)--(0,-1)--cycle;
                    \tikzset{shift={(-\i-1,-\j-1)}}
                    \path(0,2.5)node[opacity=0,xscale=.8]{WORDART};
                }
            }
        }
    \end{scope}
\end{tikzpicture}

\end{document}
Symbol 1
  • 36,855
  • 3
    Most frightening so far. Even more scary, there's a traditional font package you could use for this, too ;). – cfr Oct 31 '16 at 13:30
35

A drowning witch.

(with apologies to the late Roger Price)

\documentclass[varwidth]{standalone}
\usepackage{pict2e}
\begin{document}
\begin{picture}(200,200)
\thicklines
\put(10,10){\line(0,1){180}\line(1,0){180}}
\put(190,190){\line(0,-1){180}\line(-1,0){180}}
\put(10,60){\line(1,0){180}}
\put(100,60){\line(1,2){25}}
\put(150,60){\line(-1,2){25}}
\end{picture}
\end{document}

enter image description here

Mark Wibrow
  • 70,437
33

How about some haunting Minecraft mobs like a cheeky Enderman or a hot-headed Creeper? ;)

Enderman Creeper

These were created using tikz‑3dplot and LuaTeX.

You can see the full source of the Enderman below, but all explanations can be found in linked the posts at the end of this answer.

% Enderman
\documentclass{article}

\usepackage{luacode}

\usepackage{xcolor}

\usepackage{tikz}
\usepackage{tikz-3dplot}

\usepackage[active, tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength{\PreviewBorder}{1cm}

\definecolor{endermanblack}{HTML}{000000}
\definecolor{endermangray}{HTML}{161616}
%\definecolor{endermanpurple}{HTML}{CC00FA}
%\definecolor{endermanlightpurple}{HTML}{E079FA}
\definecolor{endermanpurple}{HTML}{FF9EFF}
\definecolor{endermanlightpurple}{HTML}{FFC9FF}
\definecolor{particlecolor}{HTML}{DF4AF8}

\begin{luacode*}
    function draw_coordinate_system()
        tex.sprint("\\draw[white!50!gray,thick,->] (0,0,0) -- " ..
            "(3,0,0) node[text=white!50!gray,anchor=north east]{$x$};")
        tex.sprint("\\draw[white!50!gray,thick,->] (0,0,0) -- " ..
            "(0,3,0) node[text=white!50!gray,anchor=west]{$y$};")
        tex.sprint("\\draw[white!50!gray,thick,->] (0,0,0) -- " ..
            "(0,0,3) node[text=white!50!gray,anchor=south]{$z$};")
    end

    function matrix_scalar_multiplication(matrix, scalar)
        local rows = #matrix
        local cols = #matrix[1]
        local tmp_matrix = {}

        for i = 1, rows do
            tmp_matrix[i] = {}
            for j = 1, cols do
                tmp_matrix[i][j] = matrix[i][j] * scalar
            end
        end

        return tmp_matrix
    end

    function shift_coordinates(matrix, array)
        local matrix_rows = #matrix
        local matrix_cols = #matrix[1]
        local array_length = #array
        local tmp_matrix = {}

        if matrix_cols == array_length then
            for i = 1, matrix_rows do
                tmp_matrix[i] = {}
                for j = 1, matrix_cols do
                    tmp_matrix[i][j] = matrix[i][j] + array[j]
                end
            end

            return tmp_matrix
        else
            return nil
        end
    end

    function tikzcube(x, y, z, color)
        local side_1 = {{1, 1, -1},
            {-1, 1, -1},
            {-1, -1, -1},
            {1, -1, -1}}
        local side_2 = {{-1, 1, -1},
            {-1, 1, 1},
            {-1, -1, 1},
            {-1, -1, -1}}
        local side_3 = {{-1, -1, -1},
            {1, -1, -1},
            {1, -1, 1},
            {-1, -1, 1}}
        local side_4 = {{1, 1, -1},
            {-1, 1, -1},
            {-1, 1, 1},
            {1, 1, 1}}
        local side_5 = {{1, -1, -1},
            {1, 1, -1},
            {1, 1, 1},
            {1, -1, 1}}
        local side_6 = {{1, 1, 1},
            {-1, 1, 1},
            {-1, -1, 1},
            {1, -1, 1}}
        local cube_sides = {side_1, side_2, side_3, side_4, side_5, side_6}
        local tex_cube = ""

        for i = 1, #cube_sides do
            tex_cube = tex_cube .. "\\draw[ultra thin, fill=" .. color .. "] "

            local current_side = matrix_scalar_multiplication(cube_sides[i], 0.5)
            current_side = shift_coordinates(current_side, {x, y, z})

            local current_side_rows = #current_side
            local current_side_cols = #current_side[1]

            for j = 1, current_side_rows do
                for k = 1, current_side_cols do
                    if k == 1 then
                        tex_cube = tex_cube .. "("
                    end

                    tex_cube = tex_cube .. current_side[j][k]

                    if k ~= current_side_cols then
                        tex_cube = tex_cube .. ", "
                    else
                        tex_cube = tex_cube .. ") -- "
                    end
                end
            end

            tex_cube = tex_cube .. "cycle;"

        end

        tex.sprint(tex_cube)
    end

    function draw_head(x_pos, y_pos, z_pos)
        local color
        for x = x_pos, x_pos + 7, 1 do
            for y = y_pos, y_pos + 7, 1 do
                for z = z_pos, z_pos + 6, 1 do
                    if (x == x_pos or x == x_pos + 7 or
                        y == y_pos or y == y_pos + 7 or
                        z == z_pos or z == z_pos + 6) and
                        not (x == x_pos + 7 and y > y_pos and y < y_pos + 7 and z == z_pos) then

                        if x == x_pos + 7 and
                            (y == y_pos or y == y_pos + 2 or
                            y == y_pos + 5 or y == y_pos + 7) and
                            z == z_pos + 2 then

                            tikzcube(x, y, z, "endermanlightpurple")
                        elseif x == x_pos + 7 and
                            (y == y_pos + 1 or y == y_pos + 6) and
                            z == z_pos + 2 then

                            tikzcube(x, y, z, "endermanpurple")
                        else
                            if math.random(0, 8) < 6 then
                                color = "endermangray"
                            else
                                color = "endermanblack"
                            end
                            tikzcube(x, y, z, color)
                        end
                    end
                end
            end
        end
    end

    function draw_bodypart(x_pos, y_pos, z_pos, x_length, y_length, z_length)
        local color
        for x = x_pos, x_pos + x_length - 1, 1 do
            for y = y_pos, y_pos + y_length - 1, 1 do
                for z = z_pos, z_pos + z_length - 1, 1 do
                    if x == x_pos or x == x_pos + x_length - 1 or
                        y == y_pos or y == y_pos + y_length - 1 or
                        z == z_pos or z == z_pos + z_length - 1 then

                        if math.random(0, 8) < 6 then
                            color = "endermangray"
                        else
                            color = "endermanblack"
                        end
                        tikzcube(x, y, z, color)
                    end
                end
            end
        end
    end

    function draw_particles(x_min, x_max, y_min, y_max, z_min, z_max)
        local x
        local y
        local z
        local black_amount
        local particle_size
        local particle_scale
        local particle_count = math.random(30, 40)
        local particle

        for i = 1, particle_count, 1 do

            x = math.random(x_min, x_max)
            y = math.random(y_min, y_max)
            z = math.random(z_min, z_max)

            particle_size = math.random(1, 8)
            particle_scale = math.random(20, 100) / 100
            black_amount = math.random(0, 25)

            tex.sprint("\\tdplottransformmainscreen{" .. x .. "}{" .. y .. "}{" .. z .. "}")
            for i = 0, particle_size - 1, 1 do
                for j = 0, particle_size - 1, 1 do
                    if math.random(0, 1) == 0 and
                        ((i ~= 0 and j ~= 0) and
                        (i ~= particle_size - 1 and j ~= 0) and
                        (j ~= particle_size - 1 and i ~= 0) and
                        (i ~= particle_size - 1 and j ~= particle_size - 1)) then

                        particle = "\\filldraw[black!" .. black_amount ..
                            "!particlecolor, tdplot_screen_coords] (" ..
                            i * particle_scale * 0.25 .. "+\\tdplotresx, " ..
                            j * particle_scale * 0.25 .. "+\\tdplotresy) " ..
                            "rectangle +(" .. particle_scale .. "*0.25, " ..
                            particle_scale .. "*0.25);"

                        tex.sprint(particle)
                    end
                end
            end
        end
    end

    function draw_enderman(x_rotation, z_rotation)
        tex.sprint("\\tdplotsetmaincoords{" .. x_rotation .. "}{" .. z_rotation .. "}")
        tex.sprint("\\begin{tikzpicture}[tdplot_main_coords]")

        math.randomseed(os.time())

        draw_bodypart(3, -2, -30, 2, 2, 30) -- right arm
        draw_bodypart(3, 1, -42, 2, 2, 30) -- right leg
        draw_bodypart(3, 5, -42, 2, 2, 30) -- left leg
        draw_bodypart(2, 0, -12, 4, 8, 12) -- body
        draw_bodypart(3, 8, -30, 2, 2, 30)-- left arm
        draw_head(0, 0, 0) -- head

        draw_particles(-10, 10, -10, 10, -44, 10)
        -- draw_coordinate_system()

        tex.sprint("\\end{tikzpicture}")
    end
\end{luacode*}

\begin{document}
\luadirect{draw_enderman(70, 130)}
\end{document}

Everything explained:

szantaii
  • 4,719
  • 2
  • 36
  • 51
32

Third Addition (!)

Now that the nightmare depicted in my original answer has become real, let us try to lighten the spirits by considering @cfr’s comment about cats. I was forced to add another answer since the 30,000 character limit didn’t let me modify my previous one.

It is well-known that the effect of black magic on a formula can be quite warped by the presence of a cat; therefore, in this new version of the answer I supply starred forms of the \mathwitch and \overrightbroom commands, that add a cat on the broomstick. In this way you can use the appropriate symbol for either kind of magic. The syntax should be easy to remember, since the additional asterisk can be thought of as reminiscent of the cat.

Other changes include switching the test for the current math version to a LaTeX-style conditional and correcting some misleading comments.

Edit: Made the following changes:

  • slightly bigger cat (a little more visible at small sizes);

  • adjusted (widened) minimal size of the broom in the \overrightbroom command;

  • corrected an erroneous comment and wrong indentation of a line in the code.

Here’s the amended code:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc} % Not necessary, but recommended. % End of standard header. What follows pertains to the problem at hand.

\usepackage{amsmath} % \usepackage{amsfonts} % \usepackage{amssymb}

% Old uncle Gustavo prefers to stick to the "picture" environment: \usepackage{pict2e}

%--------------------------------------------------------------% \makeatletter

@ifdefinable\if@MWi@cat@{\newif\if@MWi@cat@}

% Drawing the larger witch: \newcommand@MWi@Large@witch[4]{% \setlength\unitlength{\fontdimen 22 #1\tw@}% \vrule @width\z@ @height 5\unitlength @depth\thr@@\unitlength \begin{picture}(12,2)(-6,-1)% \roundcap \linethickness{#3\p@}% \Line(-2,-2)(6,2)% \linethickness{#2\p@}% \Line(-2,-2)(-5,-2.5)% \Line(-2,-2)(-4.85,-2.95)% \Line(-2,-2)(-4.6,-3.3)% \Line(-2,-2)(-4.35,-3.65)% \Line(-2,-2)(-4,-4)% \Line(0,1.8)(-.2,1.4)% \polyline(.6,3.2)(.8,3)(1.5,3)% \put(1.6,3){\oval(.2,.2)[tl]}% \put(1.6,3){\oval(.2,.2)[r]}% \polyline(1.6,2.9)(1.8,2.4)(1.2,2.4)(1,2.5)(1,2.3)% (1.2,2)(1.6,1.8)(1.7,1.8)(1.7,1.6)(1.4,1.5)% (0,1.8)(-.2,2)% \polygon(-1,2)(-2,0)(-2,-1)(-1.5,-2)(1,-2)% (0,-3.6)(.4,-3.8)(.6,-3.4)(.8,-4)(2,-4)% (1,-3.6)(1,-3)(1.6,-3.2)(2,-1.5)(0,-1)% (0,-.6)(1.4,-.6)(1.8,-.4)(2,0)(0,0)% (0,1.4)% \polygon(-3,2)(-2.8,3)(-2,4)(-1.5,4.1)(-1,4)(0,3.5)% (1,3.8)(2.5,3.5)(3,3.3)(2,3.4)(0,3)(-1,2)(-2,1.6)% (-2.7,2)(-2,2)(-1,3)(-2,3.5)(-2.6,3)% \buttcap \Line(.2,2.8)(.6,3)% the witch's eye \linethickness{#4\p@}% \Line(1.7,1.6)(2,1.6)% \Line(1.7,1.6)(1.9,1.4)% \Line(1.7,1.6)(1.7,1.3)% \if@MWi@cat@ \Line(3.8,2.1)(5.2,1.9)% \Line(3.8,2)(5.2,2)% \Line(3.8,1.9)(5.2,2.1)% \roundcap \linethickness{#3\p@}% \put(3.6,1){\circle{1.2}}% \put(4.2,1.4){\circle{1}}% \put(4.5,2){\circle{.8}}% \polygon*(4.1,2)(4.1,2.5)(4.5,2.2)(4.9,2.5)(4.9,2)% \cbezier(3.2,.6)(2,0)(4.2,-.4)(3,-1)% \fi \end{picture}% }

% Drawing the smaller witch: \newcommand@MWi@Common@small@body{% \Line(0,.9)(-.1,.7)% \polyline(.3,1.6)(.4,1.5)(.75,1.5)(.9,1.2)(.5,1.2)% (.6,1)(.8,.9)(.7,.75)(0,.9)(-.1,1)% \polygon(-.5,1)(-1,0)(-1,-.5)(-.75,-1)(.5,-1)% (0,-1.8)(.2,-1.9)(.3,-1.7)(.4,-2)(1,-2)% (.5,-1.8)(.5,-1.5)(.8,-1.6)(1,-.75)(0,-.5)% (0,.7)% \polygon(-1.5,1)(-1.4,1.5)(-1,2)(-.5,2)(0,1.75)% (.5,1.9)(1.25,1.75)(0,1.5)(-.5,1)(-1,.8)% (-1.2,1)(-1,1)(-.5,1.5)(-1,1.75)(-1.3,1.5)% \buttcap \Line(.1,1.4)(.3,1.5)% the witch's eye } \newcommand@MWi@Small@witch[3]{% \setlength\unitlength{\fontdimen 22 #1\tw@}% \vrule @width\z@ @height\z@ @depth@ne\unitlength \begin{picture}(6,3)(-3,-1)% \roundcap \linethickness{#3\p@}% \Line(-1,-1)(3,1)% \linethickness{#2\p@}% \Line(-1,-1)(-2.5,-1.25)% \Line(-1,-1)(-2.4,-1.5)% \Line(-1,-1)(-2.25,-1.75)% \Line(-1,-1)(-2,-2)% \polygon*(0,-.3)(.7,-.3)(.9,-.2)(1,0)(0,0)% @MWi@Common@small@body \if@MWi@cat@ @MWi@Common@small@cat{#3}% \fi \end{picture}% }

% Drawing the smaller cat: \newcommand@MWi@Common@small@cat[1]{% \roundcap \linethickness{#1\p@}% \put(1.8,.5){\circle{.6}}% \put(2.1,.7){\circle{.5}}% \put(2.25,1){\circle{.4}}% \polygon*(2.05,1)(2.05,1.25)(2.25,1.1)(2.45,1.25)(2.45,1)% \cbezier(1.8,.4)(1.2,.1)(2,-.1)(1.4,-.4)% }

% Helper macros for "\overrightbroom": \newcommand@MWi@mathpalette[8]{% % A version of "\mathpalette" adapted to our needs, in which % the macro passed in #1 must take six arguments, as follows: % #1 := style selection for main style % #2 := style selection for "relative-script" style % #3 := font family selector (e.g., "\scriptfont") % #4 := 1st user-defined parameter % #5 := 2nd user-defined parameter % #6 := main argument % Below, we'll use the user-defined parameters to pass the line % thicknesses for the face of the witch and the tail of the cat. % % The parameters for a call to this macro are the following: % #1 := target macro % #2 := value of 1st user-defined parameter for text/display style % #3 := value of 1st user-defined parameter for script style % #4 := value of 1st user-defined parameter for scripscript style % #5 := value of 2nd user-defined parameter for text/display style % #6 := value of 2nd user-defined parameter for script style % #7 := value of 2nd user-defined parameter for scripscript style % #8 := main argument of target macro \mathchoice {#1\displaystyle \scriptstyle \scriptfont {#2}{#5}{#8}}% {#1\textstyle \scriptstyle \scriptfont {#2}{#5}{#8}}% {#1\scriptstyle \scriptscriptstyle \scriptscriptfont {#3}{#6}{#8}}% {#1\scriptscriptstyle \scriptscriptstyle \scriptscriptfont {#4}{#7}{#8}}% } \newcommand@MWi@overarrow@with@witch[7]{% % #1 := stretchable covering arrow % #2 := base style % #3 := style for covering arrow % #4 := font family selector (e.g., "\scriptfont") % #5 := line thickness for the witch % #6 := line thickness for the cat % #7 := base symbol \vbox{\ialign{##\crcr % the cat: \if@MWi@cat@ \hskip \z@ @plus \thr@@ fil @MWi@Small@cat@on@hori@broomstick#4{#6}% \hfil\crcr \noalign{\nointerlineskip}% \fi % the centered witch: \hfil@MWi@Small@witch@wo@broom #4{#5}\hfil\crcr \noalign{\nointerlineskip}% % the covering broom: #1#3\crcr \noalign{\nointerlineskip}% % the covered subformula: $\m@th\hfil #2#7\hfil$\crcr }}% }

% Drawing the small witch w/o the broom: \newcommand@MWi@Small@witch@wo@broom[2]{% \setlength\unitlength{\fontdimen 22 #1\tw@}% \begin{picture}(8,4)(-4,-2)% \linethickness{#2\p@}% \polygon(-.1,.4)(1,-.9)(1,-1.2)(.8,-1.2)(-.1,0)% @MWi@Common@small@body \end{picture}% }

% Drawing the cat on a horizontal broomstick: \newcommand*@MWi@Small@cat@on@hori@broomstick[2]{% \setlength\unitlength{\fontdimen 22 #1\tw@}% \begin{picture}(0,0)(2,3.4)% @MWi@Common@small@cat{#2}% \Line(2.2,.8)(2.4,.4)% \end{picture}% }

% Extensible broom (stub): % \DeclareMathSymbol{@MWi@left@broom@tail} {\mathrel}{AMSa}{"4B} % \DeclareMathSymbol{@MWi@right@broom@tail}{\mathrel}{AMSa}{"4C} \newcommand*@MWi@rightbroomfill@{% \arrowfill@{% \smash[t]% % \smash % another possibility {\ni}% % {\Rrightarrow}% another possibility % {@MWi@left@broom@tail}% yet another possibility }\relbar\relbar }

% Checking the math version: \newcommand*@MWi@if@bold@math{% \def@tempa{bold}% \ifx\math@version@tempa \expandafter@firstoftwo \else \expandafter@secondoftwo \fi }

% User-level commands: \newcommand\mathwitch{% @ifstar {@MWi@cat@true @MWi@mathwitch}% {@MWi@cat@false @MWi@mathwitch}% } \newcommand@MWi@mathwitch{% \mathop{% @MWi@if@bold@math{% \mathchoice{% @MWi@Large@witch \textfont {.6}{1.2}{.15}% }{% @MWi@Small@witch \textfont {.4}{}% }{% @MWi@Small@witch \scriptfont {.3}{.6}% }{% @MWi@Small@witch \scriptscriptfont {.15}{.4}% }% }{% \mathchoice{% @MWi@Large@witch \textfont {.3}{.8}{.1}% }{% @MWi@Small@witch \textfont {.2}{.5}% }{% @MWi@Small@witch \scriptfont {.15}{.3}% }{% @MWi@Small@witch \scriptscriptfont {.1}{.2}% }% }% }% \displaylimits % as per default } \newcommand\overrightbroom{% RETHINK: not enough general! @ifstar {@MWi@cat@true @MWi@overrightbroom}% {@MWi@cat@false @MWi@overrightbroom}% } \newcommand@MWi@overrightbroom{% @MWi@if@bold@math{% @MWi@mathpalette {@MWi@overarrow@with@witch@MWi@rightbroomfill@}% {.3}{.15}{.15}% line thicknesses for the face {.6}{.4}{.4}% line thicknesses for the tail }{% @MWi@mathpalette {@MWi@overarrow@with@witch@MWi@rightbroomfill@}% {.15}{.1}{.1}% line thicknesses for the face {.3}{.2}{.2}% line thicknesses for the tail }% }

\makeatother %--------------------------------------------------------------%

\begin{document}

A reduction my students are likely to make: [\mathwitch \frac{\sin x}{s} = x,\mathrm{in}] The same reduction as an in-line formula: (\mathwitch \frac{\sin x}{s} = x,\mathrm{in}).

Test for ``operator-like'' behavior: $\mathwitch x$ versus $\mathwitch(x)$---does anybody note the difference? Let us also check that our $\mathwitch$~symbol does not make the lines further apart than usual. Here it is again:\nobreak\space $\mathwitch* b$. A few more words to have enough plain lines in the paragraph to make it possible to compare the leading. Was that enough? No, it wasn't: we'd like to get at least one line further.

Now with limits: [ \mathwitch_{i=1}^{n} \frac {\text{$i$-th magic term}} {\text{$2^{i}$-th wizardry}} ] And repeated in-line: ( \mathwitch_{i=1}^{n} x_{i}y_{i} ).

Test for other math styles: subscript~$F_{!\mathwitch\alpha}$, in-line fraction ( \frac{\mathwitch m}{\mathwitch* n} ), double superscript ( 2^{2^{\mathwitch* \aleph_{0}}} ) (this one looks really awkward!).

\begingroup \Huge Look at the details of the display-style version: [ \mathwitch* \genfrac{<}{>}{0pt}{} {\text{something terribly}}{\text{complicated}} = 0 ] Please note the beard\ldots~:-)\par \endgroup

Now we've also got the \texttt{bold} math version:\mathversion{bold} [ \mathwitch* \genfrac{<}{>}{0pt}{} {\textbf{something terribly}}{\textbf{complicated}} = 0 ] Compare it with \texttt{normal} math\mathversion{normal}: [ \mathwitch* \genfrac{<}{>}{0pt}{} {\text{something terribly}}{\text{complicated}} = 0 ] In-line math comparison: {\boldmath $\mathwitch* f(x)$} versus $\mathwitch* f(x)$.

The \verb|\overrightbroom| command, both in-line ( \overrightbroom{x_{1}+\dots+x_{n}} ) and displayed: \begin{align} \overrightbroom{x_{1}+\dots+x_{n}} &= 0 & \overrightbroom{f(x+y)} &= \overrightbroom{h(z)}+\overrightbroom{g(z)} \end{align*}

\begingroup

\bfseries \mathversion{bold}

Again in bold: in-line
\( \overrightbroom{x_{1}+\dots+x_{n}} \)
and displayed:
\begin{align*}
    \overrightbroom{x_{1}+\dots+x_{n}} &amp;= 0 &amp;
    \overrightbroom*{f(x+y)} &amp;= \overrightbroom{h(z)}+\overrightbroom{g(z)}
\end{align*}

\endgroup

Text style ( \overrightbroom{x_{1}+\dots+x_{n}}=0 ) versus script style ( P_{\overrightbroom{x_{1}+\dots+x_{n}}} ). Minimal size:\nobreak\space $\overrightbroom*{}$.

\end{document}

And here’s the output it produces:

Output of the above code

As one can expect, the cat is almost invisible…

Announcement

The halloweenmath package is now available on CTAN! This makes it possible to re-write all previous answers by simply making them invoke this new package. Here's another example, which is actually the sample input file provided along with the package itself (note that this amounts to the fifth version of the answer!):

\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc} % not necessary, but recommended
\usepackage{halloweenmath}

\title{Sample Halloween Math} \author{A.~U.~Thor} \date{January~6, 2017}

\begin{document}

\maketitle

A reduction my students are likely to make: [\mathwitch \frac{\sin x}{s} = x,\mathrm{in}] The same reduction as an in-line formula: (\mathwitch \frac{\sin x}{s} = x,\mathrm{in}).

Now with limits: [ \mathwitch_{i=1}^{n} \frac {\text{$i$-th magic term}} {\text{$2^{i}$-th wizardry}} ] And repeated in-line: ( \mathwitch_{i=1}^{n} x_{i}y_{i} ).

The \texttt{bold} math version is honored:\mathversion{bold} [ \mathwitch* \genfrac{<}{>}{0pt}{} {\textbf{something terribly}}{\textbf{complicated}} = 0 ] Compare it with \texttt{normal} math\mathversion{normal}: [ \mathwitch* \genfrac{<}{>}{0pt}{} {\text{something terribly}}{\text{complicated}} = 0 ] In-line math comparison: {\boldmath $\mathwitch* f(x)$} versus $\mathwitch* f(x)$.

There is also a left-facing witch: [\reversemathwitch \frac{\sin x}{s} = x,\mathrm{in}] And here is the in-line version: (\reversemathwitch \frac{\sin x}{s} = x,\mathrm{in}).

Test for \verb|\dots|: [ \mathwitch_{i_{1}=1}^{n_{1}} \dots \mathwitch_{i_{p}=1}^{n_{p}} \frac {\text{$i_{1}$-th magic factor}} {\text{$2^{i_{1}}$-th wizardry}} \pumpkin\dots\pumpkin \frac {\text{$i_{p}$-th magic factor}} {\text{$2^{i_{p}}$-th wizardry}} ] And repeated in-line: ( \mathwitch\dots\mathwitch_{i=1}^{n} x_{i}y_{i} ).

\bigbreak

Now the pumpkins. First the \texttt{bold} math version:\mathversion{bold}: [ \bigoplus_{h=1}^{m}\bigpumpkin_{k=1}^{n} P_{h,k} ] Then the \texttt{normal} one\mathversion{normal}: [ \bigoplus_{h=1}^{m}\bigpumpkin_{k=1}^{n} P_{h,k} ] In-line math comparison: {\boldmath ( \bigpumpkin_{i=1}^{n} P_{i} \neq \bigoplus_{i=1}^{n} P_{i} )} versus ( \bigpumpkin_{i=1}^{n} P_{i} \neq \bigoplus_{i=1}^{n} P_{i} ).

Close test: {\boldmath $\bigoplus$}$\bigoplus$. And against the pumpkins: {\boldmath $\bigpumpkin$}$\bigpumpkin\bigoplus${\boldmath $\bigoplus$}.

In-line, but with \verb|\limits|: ( \bigoplus\limits_{h=1}^{m}\bigpumpkin\limits_{k=1}^{n} P_{h,k} ).

Binary: ( x\pumpkin y \neq x\oplus y ). And in display: [ a\pumpkin\frac{x\pumpkin y}{x\oplus y}\otimes b ] Close test: {\boldmath $\oplus$}$\oplus$. And with the pumpkins too: {\boldmath $\pumpkin$}$\pumpkin\oplus${\boldmath $\oplus$}.

In general, [ \bigpumpkin_{i=1}^{n} P_{i} = P_{1}\pumpkin\dots\pumpkin P_{n} ]

\begingroup

\bfseries\boldmath

The same in bold: [ \bigpumpkin_{i=1}^{n} P_{i} = P_{1}\pumpkin\dots\pumpkin P_{n} ]

\endgroup

Other styles: ( \frac{x\pumpkin y}{2} ), exponent~$Z^{\pumpkin}$, subscript~$W_{!x\pumpkin y}$, double script ( 2^{t_{x\pumpkin y}} ).

\bigbreak

Clouds. A hypothetical identity: ( \frac{\sin^{2}x + \cos^{2}x}{\cos^{2}x} = \mathcloud ). Now the same identity set in display: [ \frac{\sin^{2}x + \cos^{2}x}{\cos^{2}x} = \mathcloud ] Now in smaller size: ( \frac{\sin x+\cos x}{\mathcloud} = 1 ).

Specular clouds, \texttt{bold}\ldots\mathversion{bold} [ \reversemathcloud \longleftrightarrow \mathcloud ] \ldots and in \texttt{normal} math.\mathversion{normal} [ \reversemathcloud \longleftrightarrow \mathcloud ] In-line math comparison: {\boldmath ( \reversemathcloud \leftrightarrow \mathcloud )} versus ( \reversemathcloud \leftrightarrow \mathcloud ). Abutting: {\boldmath $\mathcloud$}$\mathcloud$.

\bigbreak

Ghosts: ( \mathleftghost \mathghost \mathrightghost \mathghost \mathleftghost \mathghost \mathrightghost ). Now with letters: ( H \mathghost H \mathghost h \mathghost ab \mathghost f \mathghost wxy \mathghost ), and also ( 2\mathghost^{3} + 5\mathleftghost^{!2}-3\mathrightghost_{i} = 12\mathrightghost_{j}^{4} ). Then, what about~$x^{2\mathghost}$ and ( z_{!\mathrightghost+1} = z_{!\mathrightghost}^{2} + z_{\mathghost} )?

In subscripts: \begin{align} F_{\mathghost+2} &= F_{\mathghost+1} + F_{\mathghost} \ F_{!\mathrightghost+2} &= F_{!\mathrightghost+1} + F_{!\mathrightghost} \end{align} Another test: ( \mathghost | \mathrightghost | \mathghost | \mathleftghost | \mathghost | \mathrightghost | \mathghost | \mathleftghost | \mathghost ). We should also try this: ( \mathrightghost \mathleftghost \mathrightghost \mathleftghost ).

Extensible arrows: \begin{gather} A \xrightwitchonbroom[a\star f(t)]{x_{1}+\dots+x_{n}} B \xrightwitchonbroom{x+z} C \xrightwitchonbroom{} D \ A \xrightwitchonbroom[a\star f(t)]{x_{1}+\dots+x_{n}} B \xrightwitchonbroom{x+z} C \xrightwitchonbroom{} D \ A \xleftwitchonbroom[a\star f(t)]{x_{1}+\dots+x_{n}} B \xleftwitchonbroom{x+z} C \xleftwitchonbroom{} D \ A \xleftwitchonbroom[a\star f(t)]{x_{1}+\dots+x_{n}} B \xleftwitchonbroom{x+z} C \xleftwitchonbroom{} D \end{gather} And ( \overrightwitchonbroom{x_{1}+\dots+x_{n}}=0 ) versus ( \overrightwitchonbroom{x_{1}+\dots+x_{n}}=0 ); or ( \overleftwitchonbroom{x_{1}+\dots+x_{n}}=0 ) versus ( \overleftwitchonbroom{x_{1}+\dots+x_{n}}=0 ).

Hovering ghosts: ( \overrightswishingghost{x_{1}+\dots+x_{n}}=0 ). You might wonder whether there is enough space left for the swishing ghost; let's try again: ( \overrightswishingghost{(x_{1}+\dots+x_{n})y}=0 ). As you can see, there is enough room. Lorem ipsum dolor sit amet consectetur adipisci elit. And ( \overrightswishingghost{\mathstrut} ) too. \begin{gather} A \xrightswishingghost[a\star f(t)]{x_{1}+\dots+x_{n}} B \xrightswishingghost{x+z} C \xrightswishingghost{} D \ A \xleftswishingghost[a\star f(t)]{x_{1}+\dots+x_{n}} B \xleftswishingghost{x+z} C \xleftswishingghost{} D \end{gather} Another hovering ghost: ( \overleftswishingghost{x_{1}+\dots+x_{n}}=0 ).. Lorem ipsum dolor sit amet consectetur adipisci elit. Ulla rutrum, vel sivi sit anismus oret, rubi sitiunt silvae. Let's see how it looks like when the ghost hovers on a taller formula, as in ( \overrightswishingghost{H_{1}\oplus\dots\oplus H_{k}} ). Mmmh, it's suboptimal, to say the least.\footnote{We'd better try ( \underleftswishingghost{y_{1}+\dots+y_{n}} ), too; well, this one looks good!}

Under ``arrow-like'' symbols: ( \underleftswishingghost{x_{1}+\dots+x_{n}}=0 ) and ( \underrightswishingghost{x+y+z} ). There are ( \underleftwitchonbroom{x_{1}+\dots+x_{n}}=0 ) and ( \underrightwitchonbroom{x+y+z} ) as well.

\bigbreak

A comparison between the standard'' and thescript-style'' over\slash under extensible arrows: \begin{align} \overrightarrow{f_{1}+\dots+f_{n}} &\neq\overscriptrightarrow{f_{1}+\dots+f_{n}} \ \overleftarrow{f_{1}+\dots+f_{n}} &\neq\overscriptleftarrow{f_{1}+\dots+f_{n}} \ \overleftrightarrow{f_{1}+\dots+f_{n}} &\neq\overscriptleftrightarrow{f_{1}+\dots+f_{n}} \ \underrightarrow{f_{1}+\dots+f_{n}} &\neq\underscriptrightarrow{f_{1}+\dots+f_{n}} \ \underleftarrow{f_{1}+\dots+f_{n}} &\neq\underscriptleftarrow{f_{1}+\dots+f_{n}} \ \underleftrightarrow{f_{1}+\dots+f_{n}} &\neq\underscriptleftrightarrow{f_{1}+\dots+f_{n}} \end{align}

\end{document}

This is the output it produces (4 pages):

Page 1 Page 2 Page 3 Page 4

If you find anything unsatisfactory in this package, blame it on its author; but if it has anything that you happen to like, please be grateful to @cfr for her challenge, without which, probably, this package would have never been written!

GuM
  • 21,558
  • 4
    This MUST win!!!!!! – CarLaTeX Nov 09 '16 at 19:28
  • 2
    @CarLaTeX Obviously .... Though I wasn't sure whether to award it to the highest voted part of this answer, so to speak. But I think it belongs with the cats! – cfr Nov 10 '16 at 00:51
  • 2
    If I ever teach math during Haloween season, I will remember this and there shall be a dark suprise test for the students... :-D Btw, this bounty was so well deserved, thank's for putting up the contest @cfr! – Guilherme Zanotelli Nov 10 '16 at 08:03
  • 1
    @GuilhermeZ.Santos This really, really needs to become a package .... – cfr Nov 10 '16 at 23:13
  • 3
    @cfr: OK, but I‘m afraid you’ll have to wait for the package until the Christmas holidays… – GuM Nov 11 '16 at 18:52
  • 1
    @GustavoMezzetti Ooohh! Purrfect Christmas present :-). – cfr Nov 11 '16 at 22:50
  • 1
    @cfr: I’m actively working on what I’ve decided to call the halloweenmath package, but I’m afraid I cannot complete it in time to offer it “as an Epiphany present”, as I hoped to (in Italian we say “come regalo per la Befana”, where the last word has not-so-subtle connections with witches). Besides \mathwitch and \overrightbroom, it already features \overleftbroom, a \pumpkin binary symbol with its corresponding \bigpumpkin large operator, a \mathghost symbol, the \xrightbroom and \xleftbroom extensible arrows, and more. – GuM Dec 31 '16 at 00:57
  • @GustavoMezzetti Sounds fantastic! I'm looking forward to a birthday present, instead ;). (My birthday is later in January.) Or a St. David's Day present (beginning of March - Welsh patron saint). Or a Summer Solstice present ... :-) – cfr Dec 31 '16 at 14:41
  • 1
    @cfr: I’ve completed a basic version of the code. Seems to work well. Added \underrightbroom, \underleftbroom, \overrightghost, … , \underleftghost, \xrightghost, and \xleftghost; not sure about the names, though, e.g., \xrightghost should perhaps be \xrightswishingghost, and similarly for the over/under ghostly extensible math accents. In any case, I think it’s impossible for me to prepare the commented .dtx in time for submitting it to CTAN on the Epiphany day, but I’ll see what I can do! (:-) – GuM Jan 02 '17 at 00:51
  • @GustavoMezzetti I'm sure it will be worth the wait ;). – cfr Jan 02 '17 at 00:53
  • @cfr: Package halloweenmath just uploaded to CTAN! Let's see if they are willing to accept such a flippant contribution! – GuM Jan 06 '17 at 00:57
  • @GustavoMezzetti Oh, they will. If they accepted cfr-initials, they'll accept halloweenmath for sure! Can't wait :-). And it is Epiphany today, is it not? – cfr Jan 06 '17 at 01:26
  • They have accepted scsnowman, halloweenmath is 1000 times less flippant! – CarLaTeX Jan 06 '17 at 21:31
  • @CarLaTeX: They did accept the halloweenmath package too (I think they accept almost everything! ;-) . – GuM Jan 06 '17 at 21:39
  • I'm happy of that! This is a masterpiece! – CarLaTeX Jan 06 '17 at 21:42
  • So cool! Thank you heaps for making this into a package - code sits here too often without this happening I think :-). – cfr Jan 06 '17 at 23:49
  • I'm trying to use it but I can't find it with MiKTeX, is it too early? – CarLaTeX Jan 07 '17 at 07:43
  • @CarLaTeX: As far as I can see, it has not been included in MiKTeX yet. TeXLive does already feature it (the usual, astonishing readiness of TeXLive: the package was available on the Italian mirror less than 30 hours after I clicked on the “Upload” button of the CTAN upload form!) If you know how to install packages manually, you can download it directly from CTAN: follow the link I gave above. – GuM Jan 07 '17 at 13:30
  • 3
    Now I'm eager to use the package in my lecture notes! – egreg Jan 08 '17 at 00:09
  • @egreg: Well, I would be honored if you did! And if you have any suggestions for improvements or additions… – GuM Jan 08 '17 at 02:03
  • Just fo info: halloweenmath is now included also in MiKTeX. I had already installed it manually, of course. There's always something to learn here on TeX.SE, even from funny things: how to manually install a package, for example. – CarLaTeX Jan 10 '17 at 07:15
30

OK, it has been a rainy Saturday afternoon, but I must be crazy to have wasted more than three hours doing this…

The idea is that, since (La)TeX is a language primarily designed to handle text with math, the lack of a “math-flavored” answer (apart from Guido’s “minimalist contribution”) was a gap that ought to be filled. This answer applies well-known techniques to define a \mathwitch operator, intended for denoting the operation of applying black magic to the ensuing subformula. I’ve made this operator follow the usual conventions (\displaylimits) if used, e.g., with indexed wizardry.

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc} % Not necessary, but recommended. % End of standard header. What follows pertains to the problem at hand.

\usepackage{amsmath}

% Old uncle Gustavo prefers to stick to the "picture" environment: \usepackage{pict2e} \usepackage{lipsum}

%--------------------------------------------------------------% \makeatletter

\newcommand@MCl@Large@witch[1]{% \setlength\unitlength{\fontdimen 22 #1\tw@}% \vrule @width\z@ @height 5\unitlength @depth\thr@@\unitlength \begin{picture}(12,2)(-6,-1)% \linethickness{\p@}% \Line(-2,-2)(6,2)% \linethickness{.4\p@}% \Line(-2,-2)(-5,-2.5)% \Line(-2,-2)(-4.85,-2.95)% \Line(-2,-2)(-4.6,-3.3)% \Line(-2,-2)(-4.35,-3.65)% \Line(-2,-2)(-4,-4)% \Line(0,1.8)(-.2,1.4)% \polyline(.6,3.2)(.8,3)(1.5,3)% \put(1.6,3){\oval(.2,.2)[tl]}% \put(1.6,3){\oval(.2,.2)[r]}% \polyline(1.6,2.9)(1.8,2.4)(1.2,2.4)(1,2.5)(1,2.3)% (1.2,2)(1.6,1.8)(1.7,1.8)(1.7,1.6)(1.4,1.5)% (0,1.8)(-.2,2)% \Line(.2,2.8)(.6,3)% \polygon(-1,2)(-2,0)(-2,-1)(-1.5,-2)(1,-2)% (0,-3.6)(.4,-3.8)(.6,-3.4)(.8,-4)(2,-4)% (1,-3.6)(1,-3)(1.6,-3.2)(2,-1.5)(0,-1)% (0,-.6)(1.4,-.6)(1.8,-.4)(2,0)(0,0)% (0,1.4)% \polygon(-3,2)(-2.8,3)(-2,4)(-1.5,4.1)(-1,4)(0,3.5)% (1,3.8)(2.5,3.5)(3,3.3)(2,3.4)(0,3)(-1,2)(-2,1.6)% (-2.7,2)(-2,2)(-1,3)(-2,3.5)(-2.6,3)% \linethickness{.1\p@}% \Line(1.7,1.6)(2,1.6)% \Line(1.7,1.6)(1.9,1.4)% \Line(1.7,1.6)(1.7,1.3)% \end{picture}% } \newcommand@MCl@Small@witch[3]{% \setlength\unitlength{\fontdimen 22 #1\tw@}% \vrule @width\z@ @height \thr@@\unitlength @depth@ne\unitlength \begin{picture}(6,2)(-3,-1)% \linethickness{#3\p@}% \Line(-1,-1)(3,1)% \linethickness{#2\p@}% \Line(-1,-1)(-2.5,-1.25)% \Line(-1,-1)(-2.4,-1.5)% \Line(-1,-1)(-2.25,-1.75)% \Line(-1,-1)(-2,-2)% \Line(0,.9)(-.1,.7)% \polyline(.3,1.6)(.4,1.5)(.75,1.5)(.9,1.2)(.5,1.2)% (.6,1)(.8,.9)(.7,.75)(0,.9)(-.1,1)% \Line(.1,1.4)(.3,1.5)% \polygon(-.5,1)(-1,0)(-1,-.5)(-.75,-1)(.5,-1)% (0,-1.8)(.2,-1.9)(.3,-1.7)(.4,-2)(1,-2)% (.5,-1.8)(.5,-1.5)(.8,-1.6)(1,-.75)(0,-.5)% (0,-.3)(.7,-.3)(.9,-.2)(1,0)(0,0)% (0,.7)% \polygon(-1.5,1)(-1.4,1.5)(-1,2)(-.5,2)(0,1.75)% (.5,1.9)(1.25,1.75)(0,1.5)(-.5,1)(-1,.8)% (-1.2,1)(-1,1)(-.5,1.5)(-1,1.75)(-1.3,1.5)% \end{picture}% }

% User-level command: \newcommand*\mathwitch{% \mathop{% \mathchoice{% @MCl@Large@witch \textfont }{% @MCl@Small@witch \textfont {.3}{.8}% }{% @MCl@Small@witch \scriptfont {.2}{.5}% }{% @MCl@Small@witch \scriptscriptfont {.1}{.3}% }% }% \displaylimits % as per default }

\makeatother %--------------------------------------------------------------%

\begin{document}

A reduction my students are likely to make: [\mathwitch \frac{\sin x}{s} = x,\mathrm{in}] The same reduction as an in-line formula: (\mathwitch \frac{\sin x}{s} = x,\mathrm{in}).

Test for ``operator-like'' behavior: $\mathwitch x$ versus $\mathwitch(x)$---does anybody note the difference? Let us also check that our $\mathwitch$~symbol does not make the lines further apart than usual. Here it is again:\nobreak\space $\mathwitch b$. \lipsum*[2]

Now with limits: [ \mathwitch_{i=1}^{n} \frac {\text{$i$-th magic term}} {\text{$2^{i}$-th wizardry}} ] And repeated in-line: ( \mathwitch_{i=1}^{n} x_{i}y_{i} ).

Test for other math styles: subscript~$F_{!\mathwitch\alpha}$, in-line fraction ( \frac{\mathwitch m}{\mathwitch n} ), double superscript ( 2^{2^{\mathwitch\aleph_{0}}} ) (this one looks really awkward!).

\begingroup \Huge Look at the details of the display-size version: [ \mathwitch \genfrac{<}{>}{0pt}{} {\text{something terribly}}{\text{complicated}} = 0 ] Please note the beard\ldots~:-)\par \endgroup

\end{document}

The output of this sample page:

Sample page

Addition

Wasted more time (only twenty minutes or so, fortunately…) to provide support for the bold math version:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc} % Not necessary, but recommended. % End of standard header. What follows pertains to the problem at hand.

\usepackage{amsmath}

% Old uncle Gustavo prefers to stick to the "picture" environment: \usepackage{pict2e} \usepackage{lipsum}

%--------------------------------------------------------------% \makeatletter

\newcommand@MCl@Large@witch[4]{% \setlength\unitlength{\fontdimen 22 #1\tw@}% \vrule @width\z@ @height 5\unitlength @depth\thr@@\unitlength \begin{picture}(12,2)(-6,-1)% \linethickness{#3\p@}% \Line(-2,-2)(6,2)% \linethickness{#2\p@}% \Line(-2,-2)(-5,-2.5)% \Line(-2,-2)(-4.85,-2.95)% \Line(-2,-2)(-4.6,-3.3)% \Line(-2,-2)(-4.35,-3.65)% \Line(-2,-2)(-4,-4)% \Line(0,1.8)(-.2,1.4)% \polyline(.6,3.2)(.8,3)(1.5,3)% \put(1.6,3){\oval(.2,.2)[tl]}% \put(1.6,3){\oval(.2,.2)[r]}% \polyline(1.6,2.9)(1.8,2.4)(1.2,2.4)(1,2.5)(1,2.3)% (1.2,2)(1.6,1.8)(1.7,1.8)(1.7,1.6)(1.4,1.5)% (0,1.8)(-.2,2)% \Line(.2,2.8)(.6,3)% \polygon(-1,2)(-2,0)(-2,-1)(-1.5,-2)(1,-2)% (0,-3.6)(.4,-3.8)(.6,-3.4)(.8,-4)(2,-4)% (1,-3.6)(1,-3)(1.6,-3.2)(2,-1.5)(0,-1)% (0,-.6)(1.4,-.6)(1.8,-.4)(2,0)(0,0)% (0,1.4)% \polygon(-3,2)(-2.8,3)(-2,4)(-1.5,4.1)(-1,4)(0,3.5)% (1,3.8)(2.5,3.5)(3,3.3)(2,3.4)(0,3)(-1,2)(-2,1.6)% (-2.7,2)(-2,2)(-1,3)(-2,3.5)(-2.6,3)% \linethickness{#4\p@}% \Line(1.7,1.6)(2,1.6)% \Line(1.7,1.6)(1.9,1.4)% \Line(1.7,1.6)(1.7,1.3)% \end{picture}% } \newcommand@MCl@Small@witch[3]{% \setlength\unitlength{\fontdimen 22 #1\tw@}% \vrule @width\z@ @height \thr@@\unitlength @depth@ne\unitlength \begin{picture}(6,2)(-3,-1)% \linethickness{#3\p@}% \Line(-1,-1)(3,1)% \linethickness{#2\p@}% \Line(-1,-1)(-2.5,-1.25)% \Line(-1,-1)(-2.4,-1.5)% \Line(-1,-1)(-2.25,-1.75)% \Line(-1,-1)(-2,-2)% \Line(0,.9)(-.1,.7)% \polyline(.3,1.6)(.4,1.5)(.75,1.5)(.9,1.2)(.5,1.2)% (.6,1)(.8,.9)(.7,.75)(0,.9)(-.1,1)% \Line(.1,1.4)(.3,1.5)% \polygon(-.5,1)(-1,0)(-1,-.5)(-.75,-1)(.5,-1)% (0,-1.8)(.2,-1.9)(.3,-1.7)(.4,-2)(1,-2)% (.5,-1.8)(.5,-1.5)(.8,-1.6)(1,-.75)(0,-.5)% (0,-.3)(.7,-.3)(.9,-.2)(1,0)(0,0)% (0,.7)% \polygon(-1.5,1)(-1.4,1.5)(-1,2)(-.5,2)(0,1.75)% (.5,1.9)(1.25,1.75)(0,1.5)(-.5,1)(-1,.8)% (-1.2,1)(-1,1)(-.5,1.5)(-1,1.75)(-1.3,1.5)% \end{picture}% }

% User-level command: \newcommand*\mathwitch{% \def@tempa{bold}% \mathop{% \ifx\math@version@tempa \mathchoice{% @MCl@Large@witch \textfont {.6}{1.2}{.15}% }{% @MCl@Small@witch \textfont {.4}{}% }{% @MCl@Small@witch \scriptfont {.3}{.6}% }{% @MCl@Small@witch \scriptscriptfont {.15}{.4}% }% \else \mathchoice{% @MCl@Large@witch \textfont {.3}{.8}{.1}% }{% @MCl@Small@witch \textfont {.2}{.5}% }{% @MCl@Small@witch \scriptfont {.15}{.3}% }{% @MCl@Small@witch \scriptscriptfont {.1}{.2}% }% \fi }% \displaylimits % as per default }

\makeatother %--------------------------------------------------------------%

\begin{document}

A reduction my students are likely to make: [\mathwitch \frac{\sin x}{s} = x,\mathrm{in}] The same reduction as an in-line formula: (\mathwitch \frac{\sin x}{s} = x,\mathrm{in}).

Test for ``operator-like'' behavior: $\mathwitch x$ versus $\mathwitch(x)$---does anybody note the difference? Let us also check that our $\mathwitch$~symbol does not make the lines further apart than usual. Here it is again:\nobreak\space $\mathwitch b$. \lipsum*[2]

Now with limits: [ \mathwitch_{i=1}^{n} \frac {\text{$i$-th magic term}} {\text{$2^{i}$-th wizardry}} ] And repeated in-line: ( \mathwitch_{i=1}^{n} x_{i}y_{i} ).

Test for other math styles: subscript~$F_{!\mathwitch\alpha}$, in-line fraction ( \frac{\mathwitch m}{\mathwitch n} ), double superscript ( 2^{2^{\mathwitch\aleph_{0}}} ) (this one looks really awkward!).

\begingroup \Huge Look at the details of the display-style version: [ \mathwitch \genfrac{<}{>}{0pt}{} {\text{something terribly}}{\text{complicated}} = 0 ] Please note the beard\ldots~:-)\par \endgroup

Now we've also got the \texttt{bold} math version:\mathversion{bold} [ \mathwitch \genfrac{<}{>}{0pt}{} {\textbf{something terribly}}{\textbf{complicated}} = 0 ] Compare it with \texttt{normal} math\mathversion{normal}: [ \mathwitch \genfrac{<}{>}{0pt}{} {\text{something terribly}}{\text{complicated}} = 0 ] In-line math comparison: {\boldmath $\mathwitch f(x)$} versus $\mathwitch f(x)$.

\end{document}

Output:

Output of the second code sample

Second Addition

I know it is crazy to insist, but I got bewitched…

Instead of using an operator, you might want to denote the (fundamental!) operation of applying black magic to a formula by means of an extensible math accent, similar to using \overrightarrow. The following code adds an \overrightbroom command for this purpose. Note that is just a stub: its \overleftbroom counterpart is still missing.

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc} % Not necessary, but recommended. % End of standard header. What follows pertains to the problem at hand.

\usepackage{amsmath} % \usepackage{amsfonts}

% Old uncle Gustavo prefers to stick to the "picture" environment: \usepackage{pict2e}

%--------------------------------------------------------------% \makeatletter

% Drawing the larger witch: \newcommand@MWi@Large@witch[4]{% \setlength\unitlength{\fontdimen 22 #1\tw@}% \vrule @width\z@ @height 5\unitlength @depth\thr@@\unitlength \begin{picture}(12,2)(-6,-1)% \linethickness{#3\p@}% \Line(-2,-2)(6,2)% \linethickness{#2\p@}% \Line(-2,-2)(-5,-2.5)% \Line(-2,-2)(-4.85,-2.95)% \Line(-2,-2)(-4.6,-3.3)% \Line(-2,-2)(-4.35,-3.65)% \Line(-2,-2)(-4,-4)% \Line(0,1.8)(-.2,1.4)% \polyline(.6,3.2)(.8,3)(1.5,3)% \put(1.6,3){\oval(.2,.2)[tl]}% \put(1.6,3){\oval(.2,.2)[r]}% \polyline(1.6,2.9)(1.8,2.4)(1.2,2.4)(1,2.5)(1,2.3)% (1.2,2)(1.6,1.8)(1.7,1.8)(1.7,1.6)(1.4,1.5)% (0,1.8)(-.2,2)% \Line(.2,2.8)(.6,3)% \polygon(-1,2)(-2,0)(-2,-1)(-1.5,-2)(1,-2)% (0,-3.6)(.4,-3.8)(.6,-3.4)(.8,-4)(2,-4)% (1,-3.6)(1,-3)(1.6,-3.2)(2,-1.5)(0,-1)% (0,-.6)(1.4,-.6)(1.8,-.4)(2,0)(0,0)% (0,1.4)% \polygon*(-3,2)(-2.8,3)(-2,4)(-1.5,4.1)(-1,4)(0,3.5)% (1,3.8)(2.5,3.5)(3,3.3)(2,3.4)(0,3)(-1,2)(-2,1.6)% (-2.7,2)(-2,2)(-1,3)(-2,3.5)(-2.6,3)% \linethickness{#4\p@}% \Line(1.7,1.6)(2,1.6)% \Line(1.7,1.6)(1.9,1.4)% \Line(1.7,1.6)(1.7,1.3)% \end{picture}% }

% Drawing the smaller witch: \newcommand@MWi@Common@small@body{% \Line(0,.9)(-.1,.7)% \polyline(.3,1.6)(.4,1.5)(.75,1.5)(.9,1.2)(.5,1.2)% (.6,1)(.8,.9)(.7,.75)(0,.9)(-.1,1)% \Line(.1,1.4)(.3,1.5)% \polygon(-.5,1)(-1,0)(-1,-.5)(-.75,-1)(.5,-1)% (0,-1.8)(.2,-1.9)(.3,-1.7)(.4,-2)(1,-2)% (.5,-1.8)(.5,-1.5)(.8,-1.6)(1,-.75)(0,-.5)% (0,.7)% \polygon(-1.5,1)(-1.4,1.5)(-1,2)(-.5,2)(0,1.75)% (.5,1.9)(1.25,1.75)(0,1.5)(-.5,1)(-1,.8)% (-1.2,1)(-1,1)(-.5,1.5)(-1,1.75)(-1.3,1.5)% } \newcommand@MWi@Small@witch[3]{% \setlength\unitlength{\fontdimen 22 #1\tw@}% \vrule @width\z@ @height\z@ @depth@ne\unitlength \begin{picture}(6,3)(-3,-1)% \linethickness{#3\p@}% \Line(-1,-1)(3,1)% \linethickness{#2\p@}% \Line(-1,-1)(-2.5,-1.25)% \Line(-1,-1)(-2.4,-1.5)% \Line(-1,-1)(-2.25,-1.75)% \Line(-1,-1)(-2,-2)% @MWi@Common@small@body \polygon*(0,-.3)(.7,-.3)(.9,-.2)(1,0)(0,0)% \end{picture}% }

% Helper macros for "\overrightbroom": \newcommand@MWi@mathpalette[6]{% % A version of "\mathpalette" adapted to our needs, in which % the macro passed in #1 must take (at least) four arguments, % as follows: % #1 := style selection for main style % #2 := style selection for "relative-script" style % #3 := font family selector (e.g., "\scriptfont") % #4 := user-defined parameter % #5 := main argument % Below, we'll use the user-defined parameter to pass the line % thickness for drawing the face. % % The parameters for a call to this macro are the following: % #1 := target macro % #2 := value for user-defined parameter for display style % #3 := value for user-defined parameter for text style % #4 := value for user-defined parameter for script style % #5 := value for user-defined parameter for scripscript style \mathchoice {#1\displaystyle \scriptstyle \scriptfont {#2}{#6}}% {#1\textstyle \scriptstyle \scriptfont {#3}{#6}}% {#1\scriptstyle \scriptscriptstyle \scriptscriptfont {#4}{#6}}% {#1\scriptscriptstyle \scriptscriptstyle \scriptscriptfont {#5}{#6}}% } \newcommand@MWi@overarrow@with@witch[6]{% % #1 := stretchable covering arrow % #2 := base style % #3 := style for covering arrow % #4 := font family selector (e.g., "\scriptfont") % #5 := line thickness for the witch % #6 := base symbol \vbox{\ialign{##\crcr % the centered witch: \hfil@MWi@Small@witch@wo@broom #4{#5}\hfil\crcr \noalign{\nointerlineskip}% % the covering broom: #1#3\crcr \noalign{\nointerlineskip}% % the covered subformula: $\m@th\hfil #2#6\hfil$\crcr }}% }

% Drawing the small w/o the broom: \newcommand@MWi@Small@witch@wo@broom[2]{% \setlength\unitlength{\fontdimen 22 #1\tw@}% \begin{picture}(0,4)(0,-2)% \linethickness{#2\p@}% @MWi@Common@small@body \polygon(-.1,.4)(1,-.9)(1,-1.2)(.8,-1.2)(-.1,0)% \end{picture}% }

% Extensible broom (stub): % \DeclareMathSymbol{@MWi@left@broom@tail} {\mathrel}{AMSa}{"4B} % \DeclareMathSymbol{@MWi@right@broom@tail}{\mathrel}{AMSa}{"4C} \newcommand*@MWi@rightbroomfill@{% \arrowfill@{% \smash[t]% % \smash % another possibility {\ni}% % {@MWi@left@broom@tail}% another possibility }\relbar\relbar }

% Checking the math version: \newcommand*@MWi@is@bold@math{% TT\fi \def@tempa{bold}% \ifx\math@version@tempa }

% User-level commands: \newcommand\mathwitch{% \mathop{% \if@MWi@is@bold@math \mathchoice{% @MWi@Large@witch \textfont {.6}{1.2}{.15}% }{% @MWi@Small@witch \textfont {.4}{}% }{% @MWi@Small@witch \scriptfont {.3}{.6}% }{% @MWi@Small@witch \scriptscriptfont {.15}{.4}% }% \else \mathchoice{% @MWi@Large@witch \textfont {.3}{.8}{.1}% }{% @MWi@Small@witch \textfont {.2}{.5}% }{% @MWi@Small@witch \scriptfont {.15}{.3}% }{% @MWi@Small@witch \scriptscriptfont {.1}{.2}% }% \fi }% \displaylimits % as per default } \newcommand\overrightbroom[1]{% \if@MWi@is@bold@math @MWi@mathpalette {@MWi@overarrow@with@witch@MWi@rightbroomfill@}% {.3}{.3}{.15}{.15}% line thicknesses {#1}% \else @MWi@mathpalette {@MWi@overarrow@with@witch@MWi@rightbroomfill@}% {.15}{.15}{.1}{.1}% line thicknesses {#1}% \fi }

\makeatother %--------------------------------------------------------------%

\begin{document}

A reduction my students are likely to make: [\mathwitch \frac{\sin x}{s} = x,\mathrm{in}] The same reduction as an in-line formula: (\mathwitch \frac{\sin x}{s} = x,\mathrm{in}).

Test for ``operator-like'' behavior: $\mathwitch x$ versus $\mathwitch(x)$---does anybody note the difference? Let us also check that our $\mathwitch$~symbol does not make the lines further apart than usual. Here it is again:\nobreak\space $\mathwitch b$. A few more words to have enough plain lines in the paragraph to make it possible to compare the leading. Was that enough? No, it wasn't: we'd like to get at least one line further.

Now with limits: [ \mathwitch_{i=1}^{n} \frac {\text{$i$-th magic term}} {\text{$2^{i}$-th wizardry}} ] And repeated in-line: ( \mathwitch_{i=1}^{n} x_{i}y_{i} ).

Test for other math styles: subscript~$F_{!\mathwitch\alpha}$, in-line fraction ( \frac{\mathwitch m}{\mathwitch n} ), double superscript ( 2^{2^{\mathwitch\aleph_{0}}} ) (this one looks really awkward!).

\begingroup \Huge Look at the details of the display-style version: [ \mathwitch \genfrac{<}{>}{0pt}{} {\text{something terribly}}{\text{complicated}} = 0 ] Please note the beard\ldots~:-)\par \endgroup

Now we've also got the \texttt{bold} math version:\mathversion{bold} [ \mathwitch \genfrac{<}{>}{0pt}{} {\textbf{something terribly}}{\textbf{complicated}} = 0 ] Compare it with \texttt{normal} math\mathversion{normal}: [ \mathwitch \genfrac{<}{>}{0pt}{} {\text{something terribly}}{\text{complicated}} = 0 ] In-line math comparison: {\boldmath $\mathwitch f(x)$} versus $\mathwitch f(x)$.

\errorcontextlines = 1000

The \verb|\overrightbroom| command, both in-line ( \overrightbroom{x_{1}+\dots+x_{n}} ) and displayed: \begin{align} \overrightbroom{x_{1}+\dots+x_{n}} &= 0 & \overrightbroom{f(x+y)} &= \overrightbroom{h(z)}+\overrightbroom{g(z)} \end{align}

\begingroup

\bfseries \mathversion{bold}

Again in bold: in-line
\( \overrightbroom{x_{1}+\dots+x_{n}} \)
and displayed:
\begin{align*}
    \overrightbroom{x_{1}+\dots+x_{n}} &amp;= 0 &amp;
    \overrightbroom{f(x+y)} &amp;= \overrightbroom{h(z)}+\overrightbroom{g(z)}
\end{align*}

\endgroup

Text style ( \overrightbroom{x_{1}+\dots+x_{n}}=0 ) versus script style ( P_{\overrightbroom{x_{1}+\dots+x_{n}}} ).

\end{document}

And here’s the output:

Output of the third code sample

GuM
  • 21,558
  • 1
    Oh, my wickedness, that is incredibly cool! We definitely need a mathwitch package now! – cfr Nov 05 '16 at 23:34
  • 2
    Simply awesome! – egreg Nov 05 '16 at 23:49
  • OMG PICTURE MODE – Paulo Cereda Nov 06 '16 at 09:27
  • if you think three hours is too long, you don't belong to the TikZ mafia :D – percusse Nov 06 '16 at 09:58
  • 1
    I must be crazy to lose more than three hours in doing this…: TEX.SE is addictive! (Why am I commenting here instead of writing my thesis?) – CarLaTeX Nov 06 '16 at 11:10
  • @percusse: My TikZ skills are still too elementary to dare exhibit them on this site… :-) Besides, in a case like this, in which essentially every point must be specified by hand, I believe that the gain in input clarity and/or speed is very little (while the extra burden put on the TeX compiler is relevant, all the more so for a symbol contained in a \mathchoice). – GuM Nov 06 '16 at 13:44
  • If I were throwing the contest, that'd be a win, for sure. @cfr, if more things like it come up maybe it can be called mathemagics ^.^ – Guilherme Zanotelli Nov 07 '16 at 10:17
  • @GuilhermeZ.Santos: I was reflecting on cfr’s (first) comment, and indeed “the operation of applying black magic” seems enough important to deserve a package for its associated symbol… :-) – GuM Nov 07 '16 at 11:38
  • @GustavoMezzetti, maybe, if you're up for it, make a fairy wond (the whole fairy seems a bit too much work - I'd do it because I just loved this but my picture mode knowledge is close to -3) and then there'll be light magic and dark magic whitin the mathemagics! IMHO that's a cool package! :-D – Guilherme Zanotelli Nov 07 '16 at 11:50
  • Not to be critical, but it might be better named \overrightpitchfork? – cfr Nov 09 '16 at 00:47
  • @GuilhermeZ.Santos Surely that should be a separate package, mathfairy, say. Of course, attempting to load both mathwitch and mathfairy would lead to an demonic error or, at the very least, a wizardly warning. – cfr Nov 09 '16 at 00:51
  • 1
    And, of course, everybody knows that self-respecting witches have cats on the back of their broomsticks. (Presumably witches' feline companions do not share their less wizardly counterparts' distaste for travel.) – cfr Nov 09 '16 at 00:53
  • @cfr: (1) I also considered using \Rrightarrow instead of \ni, which would produce a much more convincing broom, but the problem with this solution is that the msam fonts lack a bold variant. Perhaps one could add a broomshape=... option. (2) I didn’t know about cats, but it shouldn’t be very complicated to draw one on the back of the broomstick: looking so small, it wouldn’t need main details… – GuM Nov 09 '16 at 06:18
27

For the sake of having a duck here, and to honour Harry Potter fans worldwide, here's my humble entry to the seasonal contest. :) As usual, the code is quite long for being posted here, so it's available as a GitHub Gist here.

The duck:

Quack!

Happy belated Halloween! Quack! :)

Update: relevant soundtrack here. :)

Paulo Cereda
  • 44,220
24

Two years ago I provided an image that some people commented looked too smiley, so here is the new improved 2016 version with a fierce scary growl.

enter image description here

\documentclass{article}
\usepackage{color}
\usepackage{pict2e}
\pagecolor[RGB]{255,177,69}
\begin{document}

\begin{picture}(120,200)
\thicklines
\put(100,100){\circle{150}}

\put(70,130){\line(1,-1){10}}
\put(70,130){\line(-1,-1){10}}
\put(60,120){\line(1,0){20}}

\put(130,130){\line(1,-1){10}}
\put(130,130){\line(-1,-1){10}}
\put(120,120){\line(1,0){20}}

\put(100,90){\line(1,-1){10}}
\put(100,90){\line(-1,-1){10}}
\put(90,80){\line(1,0){20}}

\put(70,50){\line(1,0){60}}
\put(70,50){\line(-2,-1){5}}
\put(130,50){\line(2,-1){5}}
\end{picture}

\end{document}
David Carlisle
  • 757,742
  • 1
    And next year a zigzag mouth? \put(70,60){\line(-1.5,-1){10}} \put(70,60){\line(1.5,-1){10}} \put(90,60){\line(-1.5,-1){10}} \put(90,60){\line(1.5,-1){10}} \put(110,60){\line(-1.5,-1){10}} \put(110,60){\line(1.5,-1){10}} \put(130,60){\line(-1.5,-1){10}} \put(130,60){\line(1.5,-1){10}} – samcarter_is_at_topanswers.xyz Oct 31 '16 at 10:58
  • 2
    I expected you to provide a TikZ solution :-). – cfr Oct 31 '16 at 12:18
  • 3
    @cfr I considered it, but the picture mode force is still strong with me – David Carlisle Oct 31 '16 at 12:22
  • 2
    Indeed - this is a day for invoking ancient traditions, after all ;). I discovered from your link that not only was there a question about this 2 years ago, but that I answered it 1 year ago. I'm glad I happened to post something different in this question, at least! – cfr Oct 31 '16 at 12:40
22

The family of Arthur's ghost Cézard with PSTricks. Arthur

http://pstricks.blogspot.fr/2011/11/synthese-additive-et-soustractive-des.html

user73104
  • 949
  • 4
    Can you include the code here rather than relying on a link? – cfr Nov 01 '16 at 23:20
  • 6
    Are you the author of that picture? I don't see any license related to the pictures or contents of that blog, which implies that all rights are reserved, including reproducing it here. The point of this question is not to earn some easy rep by ripping off random people's work without asking for permission... – Bakuriu Nov 03 '16 at 09:34
  • 2
    @Bakuriu That's only in US. And take it down a notch with the accusation please – percusse Nov 06 '16 at 16:41
5

My incubus:

\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX, Scale=MatchLowercase}
\setmainfont{Comic Sans MS}
\usepackage{lipsum}
\title{Let's Make America Great Again}
\author{Donald J. Trump}
\date{\today}
\frenchspacing
\begin{document}
\maketitle
\section{Introduction}
\lipsum[1-2]
\section{Conclusion}
\lipsum[3-4]
\end{document}

enter image description here

JFYI, note the dreadful typeface choice.

NVaughan
  • 8,175