• Challenge: Show us your best tariff tables
    by mickep on April 4, 2025 at 11:07 am

    There are too few silly "contests" here nowadays, and I really think we could need a laugh. We have likely all seen the beautiful tariff table the other day. In case somebody missed it, here is one example image of it: The challenge here is to show off, in any TeX dialect, and make your own tariff table. The sillier the better. But also fun if there is something to learn, TeX-wise, by studying your solution. I will make this post community. Have fun!

  • With a sense of humor, just for fun. TeX and 3d printers
    by user284656 on December 25, 2024 at 10:30 pm

    Please, do not be too serious. TeX is the digital version of Gutenbergs typesetting. Now, how about taking it the other way around? With TeX and modern 3d printers, it should be possible, to produce ancient matrixes. Is there something existing like that?

  • How to simplify/refactor this code even more?
    by MS-SPO on December 21, 2024 at 7:54 pm

    The following code origines from a joke in German, visualizing the answer "50 grays of Schade." (see below). The code: puts 7 x 7 tiles + 1 bigger background tile distributing in a cyclic way the characters S c h a d e . changes each tiles gray-fill randomly in a predefined way puts out a row of tiles using \foreach via \msrow{}{} (from refactoring) leaving the call to the 7 rows unrefactored (modified) Random sequence without replacement to obtain different shades (from R: sample(1:100,50,replace=FALSE)) with one error from copying, which you may or may not use as input: 37 32 80 12 55 6 17 41 44 95 9 97 88 18 8 8 14 42 11 47 68 99 73 1 5 84 81 40 21 59 43 39 64 82 38 24 85 34 89 50 20 92 65 53 67 76 23 70 30 If possible, this code should become even more compact, without sacrifycing legibility. But feel free to take different routes, too. \documentclass[10pt,border=3mm,tikz]{standalone} \newcommand\msrow[2]{% \foreach \g/\t [count=\i] in {#2}% \node[bx,fill=black!\g] at (\i,#1) {\t};} \begin{document} \begin{tikzpicture}[ % bx/.style={minimum size=1cm,text=red,font={\bf}},% see cfr's remark bx/.style={minimum size=1cm,text=red,font={\bfseries}}, ] % ~~~ background ~~~~~~~~~~~~~~~~~~~~~~~~~~ \node[fill=black!50, minimum size=8cm] at (4,4) {}; % ~~~ all those tiles ~~~~~~~~~~~~~~~~~~~~~ \msrow{7}{37/S, 32/c, 80/h, 12/a, 55/d, 6/e, 17/.} \msrow{6}{41/c, 44/h, 95/a, 9/d, 97/e, 88/., 18/S} \msrow{5}{ 8/h, 8/a, 14/d, 42/e, 11/., 47/S, 68/c} \msrow{4}{99/a, 73/d, 1/e, 5/., 84/S, 81/c, 40/h} \msrow{3}{21/d, 59/e, 43/., 39/S, 64/c, 82/h, 38/a} \msrow{2}{24/e, 85/., 34/S, 89/c, 50/h, 20/a, 92/d} \msrow{1}{65/., 53/S, 67/c, 76/h, 23/a, 70/d, 30/e} \end{tikzpicture} \end{document} Background, the joke in German: "Kannst du mir sagen, was neun auf Englisch heißt?" - Can you please tell, what's nine in English? "Nine." - Sounds exactly like: "No" (Nein) "Schade." - Too bad (looks like "shade", and sounds a bit similar, too) 50 grays of S(c)hade ...

  • Beautiful clocks using bxcoloremoji package
    by Sebastiano on November 27, 2024 at 9:33 pm

    This is a follow-up of the question A grid in a cartesian plane of clocks using clock package Starting from the answer of @Ignasi: \documentclass{article} \usepackage{clock} \usepackage{tikz} \begin{document} \begin{tikzpicture} \foreach \i in {1,...,10}{ \foreach \j [evaluate=\j as \h using {int(12*rnd)}, evaluate=\j as \m using {int(60*rnd)}] in {1,...,10} \node at (\i,\j) {\clock{\h}{\m}};} \end{tikzpicture} \end{document} is it possible to have the clocks using this recent package bxcoloremoji (v1.0a [2024/11/18])?

  • Shipout box to tempfile
    by Anthony D'Arienzo on May 27, 2024 at 6:18 pm

    I currently have a Python script which (through ImageMagick) makes a PDF appear photocopied. I am trying to migrate this process to a LaTeX class—for fun, to see what is possible in LaTeX. It seems that one way this could work is to intercept \shipout with some external calls to modify the output PDF. Using atbegshi for intercepting shipout, the procedure would look like Generate a page worth of LaTeX code. AtBeginShipout, write the contents of AtBeginShipoutBox (i.e., \Box255) to a temporary file, temppage.tex. Call pdftex on the temporary file and distort the PDF via ImageMagick to a temporary file temppage.png. Instead of shipping out the contents of AtBeginShipoutBox, shipout a box containing \includegraphics{temppage.png}. When write18 is enabled, steps (3) and (4) seem mostly straightforward. This leaves step (2). Is it possible to explicitly shipout a box to a temporary PDF? If that is not possible, perhaps there is a reliable way to echo the raw TeX of a box to a tempfile to be compiled later? The end goal is a LaTeX class which need not call another script to make the output PDF look photocopied.

  • Possible to dot your Is with hearts?
    by Infimum on April 22, 2024 at 8:13 am

    I was wondering if it is possible to replace just the mathmode i from the default latex font with nearly the same letter, but where the dot on the i is a small heart. For example: Thank you!

  • How to make an \egreg command?
    by Gaussler on April 1, 2023 at 7:31 am

    I would like a command \egreg which produces “egreg”. However, there is no reason to limit yourself to one “reg”. Who knows, maybe one day you just feel like writing “egregregregreg" for some reason. So the command should also take an optional argument, specifying the number of “reg”’s you want. I know there are easy solutions involving loops, but given that it’s April 1, the most ridiculous solution will be accepted. \documentclass{article} \NewDocumentCommand\egreg{o}{% % something } \begin{document} \egreg % should produce "egreg" \egreg[0] % should produce "eg" \egreg[1] % should produce "egreg" \egreg[2] % should produce "egregreg" \egreg[5] % should produce "egregregregregreg" Perhaps we might also want to allow negative values: \egreg[-1] % should produce "regeg" \egreg[-2] % should produce "regregeg" Maybe also complex values? \egreg[i] % perhaps "$\text{eg} + i\text{reg}$"? Perhaps someone can also figure out what to do with quaternionic values? \end{document}

  • Draw a unicorn in TikZ 🦄
    by Martin Thoma on March 31, 2023 at 2:42 pm

    I'm currently reading Sparks of Artificial General Intelligence: Early experiments with GPT-4. This paper by Microsoft employees experiments with the capabilities of GPT-4, a successor of ChatGPT. One task is to draw a unicorn with tikz.ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ They claim: GPT-4 produces impressive outputs that are [...] at least comparable (if not superior) to what a human would do. Who wants to prove them wrong? 😄🦄🌈 edit: Please don't include PNG / JPG / other pixel image formats. MS-SPO is the only one allowed to do that (as a grandfathering-rule) - kudos for finding the loophole in this question and for thinking outside of the box 😁👍 edit: We now have 200 fun questions! 🥂🥳

  • Wordle-like colored letter boxes in latex
    by valerio_new on September 28, 2022 at 2:55 pm

    I want to create some letters boxed as in the Wordle game: But so far i have not found a tool that allows me to do it. I want to embed them both in the title and in the document. How would you make them?

  • Make paragraph-formatting apply to all environments but not to short paragraphs
    by anon on February 27, 2022 at 9:11 am

    I am aware that this is a hyper specific question but I have been playing around with making all paragraphs perfect rectangles just like in this StackExchange question. And as in these older threads I am experiencing the same problems. But I am still trying to make them less bad. The first problem is probably easier to fix: The changes to parfillskip and the other parameters do not take affect in any environments like enumerate and itemize in the example below. But I also want to have rectangular paragraphs there. This is probably much harder to fix and just an idea of mine. Is it possible to make the changes to the lengths only apply when the paragraph exceeds a certain length? Maybe there is some way to get the length of a paragraph to then only use the \setlength in the preamble when the length is greater than some given length. I am also aware that this is not exactly what is intended with LaTeX as the looks should be the less important part but I still want to experiment a bit with it. Here is a minimal working example which shows the problems \documentclass[a4paper]{article} \usepackage{blindtext} \usepackage{lmodern} \usepackage[stretch=30]{microtype} \usepackage{etoolbox} % Enbale rectangular paragraphs \setlength{\parindent}{0pt} \setlength{\parskip}{.5\baselineskip} \setlength{\parfillskip}{0pt} \setlength{\emergencystretch}{.5\textwidth} \makeatletter \patchcmd{\@sect}{\begingroup}{\begingroup\parfillskip=0pt plus 1fil\relax}{}{} \patchcmd{\@ssect}{\begingroup}{\begingroup\parfillskip=0pt plus 1fil\relax}{}{} \makeatother \begin{document} Too short paragraph that gets ruined and where the changed lengths should not apply \section{Lorem ipsum} \blindtext \begin{itemize} % No affect here \item \blindtext \end{itemize} \begin{enumerate} % No affect here \item \blindtext \end{enumerate} \end{document}

  • Ghost shape in TikZ/pgf
    by JeT on October 7, 2021 at 10:09 pm

    My question I can easily draw the normal distribution thanks to this answer by Jake. What about the ghost ? Context This image always breaks the ice when teaching probabilities 🙂 (Not that I care so much about it, but Halloween is getting closer too) I presume it would be possible with Inkscape (but I am not familiar with it). This answer by Paul Gaborit uses the hobby package I tried to adapt (poorly as you'll see, far too manual to be honnest) in my MWE. I'd be happy to see different approaches too (pure tikz, pgfplot, other libraries...). \documentclass[tikz]{standalone} \usetikzlibrary{hobby} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture}[use Hobby shortcut] \draw[ help lines, line width=0.1pt, blue, ] (-20, -20) grid[step={($(5, 5) - (0, 0)$)}] (60, 100); \path (0,0) coordinate (z0) (10,10) coordinate (z1) (20,0) coordinate (z2) (30,10) coordinate (z3) (40,0) coordinate (z4) (50,10) coordinate (z5) (30,90) coordinate (z6) (0,70) coordinate (z7) (0,60) coordinate (z8) ; \draw[closed,black, line width= 3mm] (z0) .. (z1) .. (z2) .. (z3) .. (z4) .. (z5).. (z6).. (z7).. (z8); \end{tikzpicture} \end{document}

  • Draw arrows from reference to figure
    by Thorbjørn E. K. Christensen on July 18, 2019 at 6:00 am

    I just fell over this gem of a figure reference system in the Danish on train magazine "ud & Se" (out and watch), and I wondered if there was a way of doing it in LaTeX. The idea is, that instead of using a caption, and reference by number, the text referencing a figure will be emphasized (bold, underlined or both) and an arrow will be drawn from the bottom center of the text to the figure. The arrow can be either curved (as in the picture below) or move in cardinal directions, if the latter is the case, the arrow should avoid text while moving horizontally, but collide with text when moving vertically (at least that's what the magazines do) Pic: I guess the way to do this in LaTeX would be something like overlaying a tikzpicture which has both the figure and the reference, and then drawing an arrow, but I don't really know anything further than that. I realize that the feature is mostly useless, but it would be fun for gags (I can see it used in my student magazine as a joke)

  • Welcoming 2019 Lunar New Year: How to draw a (lovely) pig?
    by user156344 on February 4, 2019 at 8:52 am

    Chinese Zodiac and Lunar Year can be called very close friends. In Eastern cultures, each lunar year is assigned to one of the twelve animals in Chinese zodiac. The animal (or rather a mascot) of this year is the pig. So, my question in this question is: How to draw a (lovely) pig in LaTeX? I found a very beautiful picture on TeXample: % Author M.R.C. van Dongen % Draw parameterised pig. % This code can/should be improved by using the pgfkey library. \documentclass{minimal} \usepackage{tikz} \usetikzlibrary{calc} \usepackage{keyval} \makeatletter % We're not using pgfkeys, and we've chosen to use keyval % for option parsing. The following define the keys for a % pig keyval family. The main purpose of the keys and % default values is that we want to be able to draw pigs % with predefined colours for certain parts and predefined % scaling factors for line thickness. \def\pig@draw@thick@width{0.85} \def\pig@draw@thin@width{0.20} \def\pig@label{pig label} \tikzset{draw thick/.style={draw=black,line width=0.85}} \tikzset{draw thin/.style={draw=black,line width=0.20}} \tikzset{fill colour/.style={fill=pink}} \tikzset{nose hole fill colour/.style={fill=purple!50!gray}} \tikzset{eye fill colour/.style={fill=white}} \tikzset{pupil fill colour/.style={fill=black}} \define@key{pig}{draw thick}{\def\draw@pig@thick@width{#1}} \define@key{pig}{draw thin}{\def\draw@pig@thin@width{#1}} \define@key{pig}{fill colour}{\tikzset{fill colour/.style={fill=#1}}} \define@key{pig}{nose hole fill colour}{\tikzset{nose hole fill colour/.style={fill=#1}}} \define@key{pig}{eye fill colour}{\tikzset{eye fill colour/.style={fill=#1}}} \define@key{pig}{pupil fill colour}{\tikzset{pupil fill colour/.style={fill=#1}}} \define@key{pig}{pig label}{\def\pig@label{#1}} \def\pig@scale{1} \def\pig{\@ifnextchar[\draw@pig{\draw@pig[]}} \def\draw@pig[#1]#2{% % Set the relative line width for thick lines. \def\draw@pig@thick@width{0.85} % Set the relative line width for thin lines. \def\draw@pig@thin@width{0.20} % Set the relative scale of the pig. \def\pig@scale{#2} \setkeys{pig}{#1} \begin{tikzpicture}[scale=#2, draw thick/.style={draw=black,line width=\draw@pig@thick@width*\pig@scale}, draw thin/.style={draw=black,line width=\draw@pig@thin@width*\pig@scale}] \path (0,0) coordinate (\pig@label head) + (-0.005,-0.20) coordinate (\pig@label nose) + (-0.010,+0.05) coordinate (\pig@label body) + (-0.010,+0.45) coordinate (\pig@label tail); % Define points for tail. \foreach \number/\point in {1/{+0.000,+0.055},% 2/{-0.058,+0.075},% 3/{+0.044,+0.094},% 4/{-0.072,+0.137},% 5/{+0.048,+0.170},% 6/{-0.078,+0.206}} { \path (\pig@label tail) +(\point) coordinate (tail \number); } % Define points for ears and legs. \foreach \offset in {-1,1} { \path (\pig@label head) ++ (+0.12*\offset,+0.00) coordinate (ear pt 1 \offset) + (-0.04*\offset,+0.07) coordinate (ear pt 2 \offset) + (-0.02*\offset,+0.25) coordinate (ear pt 3 \offset) + (+0.11*\offset,+0.25) coordinate (ear pt 4 \offset) + (+0.14*\offset,+0.13) coordinate (ear pt 5 \offset) + (+0.09*\offset,-0.06) coordinate (ear pt 6 \offset) (\pig@label head) ++ (+0.09*\offset,-0.30) coordinate (leg 1 \offset) ++ (+0.01*\offset,-0.24) coordinate (leg 2 \offset) ++ (+0.04*\offset,+0.08) coordinate (leg 3 \offset) ++ (+0.04*\offset,-0.08) coordinate (leg 4 \offset) ++ (+0.02*\offset,+0.30) coordinate (leg 5 \offset); } % draw legs. \foreach \number in {-1,1} { \filldraw[fill colour,draw thick] (leg 1 \number) -- (leg 2 \number) -- (leg 3 \number) -- (leg 4 \number) -- (leg 5 \number) -- cycle; } % draw tail. \draw[draw thick,line join=round,line cap=round] (\pig@label tail) \foreach \num in {1,...,6} { -- (tail \num)}; % draw body. \draw[fill colour,draw thick] (\pig@label body) ellipse (4.50mm and 4.10mm); % draw ears. \foreach \number in {-1,1} { % ears \filldraw[fill colour,draw thick] (ear pt 1 \number) .. controls (ear pt 2 \number) and (ear pt 3 \number) .. (ear pt 4 \number) .. controls (ear pt 5 \number) and (ear pt 6 \number) .. (ear pt 1 \number); } % draw nose. \filldraw[fill colour,draw thick] (\pig@label head) ellipse (1.42mm and 1.40mm); \foreach \offset in {-1,1} { \filldraw[draw thin,eye fill colour] (\pig@label head) ++ (-0.006,0.00) ++ (0.055*\offset,+0.03) coordinate (eye \offset) ellipse (0.04 and 0.060); \fill[pupil fill colour] (eye \offset) ellipse (0.020 and 0.035); } \filldraw[fill colour,draw thick] (\pig@label nose) ellipse (2.60mm and 1.72mm); % Draw nose holes \foreach \offset in {-1,1} { \filldraw[draw thick,nose hole fill colour] (\pig@label nose) ++ (\offset*0.080,0) ellipse (0.50mm and 0.85mm); } \end{tikzpicture} } \makeatother \begin{document} \begin{tikzpicture} \draw (0,0) node[anchor=south]{\pig{3}} (4,0) node[anchor=south]{\pig[nose hole fill colour=purple!20,fill colour=blue!40]{5}}; \end{tikzpicture} \end{document} However, I wish to see more pigs here, especially with other familiar animals, like lions, ducks, marmots, bears, rabbits, birds, donkeys, or penguins. I am also looking for a tikzlings pig!

  • Making a working neuronal network [closed]
    by current_user on October 11, 2018 at 12:47 pm

    I've got the following two MWE: \documentclass[border=5pt,tikz]{standalone} \begin{document} \begin{tikzpicture} %%% %%% %%% %>> We are building a perceptron %%% %%% %%% % input vectors \xdef\firstinputarray{{1,2}} \xdef\secondinputarray{{4,8}} % output vector \xdef\outputarray{{1,0}} % The 1 means that for \firstinputarray the statement is true, for \secondinputarray is wrong % weights \xdef\zerow{.5} \xdef\firstw{2} \xdef\secondw{1.75} % bias \xdef\bias{1} % Heaviside \newcommand{\heaviside}[1]{ \ifnum#1>0 \pgfmathsetmacro{\a}{1} \fi \ifnum#1=0 \pgfmathsetmacro{\a}{1} \fi \ifnum#1<0 \pgfmathsetmacro{\a}{0} \fi } % Floor function \newcommand{\floor}[1]{ \pgfmathsetmacro{\floornumber}{int(floor(#1))} } \newcommand{\forheavi}[1]{ \pgfmathsetmacro{\forheavinumber}{int(floor(#1))} } % new weights \pgfmathsetmacro{\firstway}{\zerow*\bias+\firstinputarray[0]*\firstw+\firstinputarray[1]*\secondw} \forheavi{\firstway} \heaviside{\forheavinumber} \node (a) {\texttt{firstway}: \pgfmathprintnumber{\firstway}\qquad$\mathrm{H}(\mathtt{firstway})$:\pgfmathprintnumber{\a}}; % set new weights \ifnum\a>0 \pgfmathsetmacro{\firstw}{.5*(\firstway-0)*\firstinputarray[0]} \fi \forheavi{\firstway} \heaviside{\forheavinumber} \node[above left,yshift=1cm] at (a.north east) {new \texttt{firstw}: \pgfmathprintnumber{\firstw}\qquad$\mathrm{H}(\mathtt{new fistw})$: \pgfmathprintnumber{\a}}; % \forheavi{0} % \heaviside{\forheavinumber} % \node[red,draw,below=.5cm] at (a) {\pgfmathprintnumber{\a}}; \end{tikzpicture} \end{document} and \documentclass[border=5pt,tikz]{standalone} \usetikzlibrary{decorations.pathreplacing} \tikzset{ neuron/.style={ draw,circle,inner sep=.3cm,fill=white }, brace/.style={ decorate,decoration={brace,amplitude=.3cm},thick } } \begin{document} \begin{tikzpicture} \foreach \x in {0,1,...,8} { \node[neuron] (a\x) at (0,\x) {}; } \foreach \y in {-4,-3,...,12} { \node[neuron] (b\y) at (8,\y) {}; } \foreach \z in {-2,-1,...,10} { \node[neuron] (c\z) at (16,\z) {}; \pgfmathsetmacro{\n}{10-\z} \draw[->] (c\z) --+ (1,0) node[right] {\pgfmathprintnumber{\n}}; } \foreach \x in {0,1,...,8} \foreach \y in {-4,-3,...,12} \foreach \z in {-2,-1,...,10} { \draw[->] (a\x) -- (b\y); \draw[->] (b\y) -- (c\z); } \draw[brace] ([xshift=-1cm]a0.south) -- ([xshift=-1cm]a8.north) node[midway,text width=2.5cm,left=.5cm] { \begin{tabular}{c} input layer \\ (784 neurons) \end{tabular} }; \node[above=1cm] at (b12) { \begin{tabular}{c} hidden layer \\ ($n = 15$ neurons) \end{tabular} }; \node[above=1cm] at (c10) { \begin{tabular}{c} output layer \end{tabular} }; \end{tikzpicture} \end{document} with the following output: I've got the following questions: How can I achieve that I can enter the input arrays and the starting weights and the first code does the calculations (more precisely: how can I “extend“ the foreach loop so that the algorithm stops when the right resulst is achieved) and How can I than highlight the weights visual e.g. I let TikZ draw two nodes (which represent neurons) and the more “important“ a bond is the line (which connects the two neurons) gets thicker (this all happens step for step, so that we can create a little animation)? P.S.: The feedforward network doesn't need to have such a big amount of neurons, this is just an illustration.

  • TikZ and FIFA WorldCup 2018: Flags of Nations
    by Black Mild on June 26, 2018 at 5:19 pm

    I am a kind of TikZ addict, and also be a fan of football. This time - WorldCup 2018 - is nice change of relaxing by drawing flags of 32 football teams by pure TikZ or TikZ-based codes. Some are easy (like the Japan flag ^^), some are somehow difficult! Please join and/or suggest me! Let me start with the South-Korean flag. In its code, I like the way of (i) drawing the Yin Yang symbols and the 4 black trigrams via only one parameter \YYrotation; (ii) using scope, foreach, and (iii) using a trick of coloring black/white trigrams with a little bit bigger line width. I first draw trigrams at (0,0), then use rotation and shift to move to the corners. Description of the South-Korean flag can be found here https://en.wikipedia.org/wiki/Flag_of_South_Korea The followings are the TikZ codes for the South-Korean flag. % Description of The SOUTH-KOREAN FLAG % https://en.wikipedia.org/wiki/Flag_of_South_Korea % A rectangle: width = 2/3 length, % the Yin Yang symbol (red above, blue below) at center, % the 4 black trigrams at 4 corners. \documentclass[border=5mm]{standalone} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \def\a{7.5} % a half of the length \def\b{5} % a half of the width \def\r{1.25} % radius of the Yin/Yang symbol % radius of the big circle \pgfmathsetmacro{\R}{2*\r} % the rotation angle of Yin/Yang/trigrams \pgfmathsetmacro{\YYrotation}{atan(3/2)} % the whole rectangle of the flag \path (-\a,-\b) rectangle (\a,\b); % the Yin Yang symbol: draw, then rotate \begin{scope}[rotate=\YYrotation] \fill[red] (0,\R) arc (90:-90:\R) arc(-90:90:\r) arc(270:90:\r); \fill[blue] (0,-\R) arc (270:90:\R) arc(90:270:\r) arc(90:-90:\r); \end{scope} % the spring trigram (the above-left corner) \begin{scope}[rotate=\YYrotation,shift={(0,4.6)},line width=.42 cm] \foreach \j in {0,5/8,-5/8} \draw (-5/4,\j)--(5/4,\j); \end{scope} % the autumn trigram (the below-left corner) \begin{scope}[rotate=-\YYrotation,shift={(0,-4.6)},line width=.42 cm] \foreach \j in {0,5/8,-5/8} \draw (-5/4,\j)--(5/4,\j); \draw[white,line width=.44 cm] (-5/48,0)--(5/48,0); \end{scope} % the winter trigram (the above-right corner) \begin{scope}[rotate=-\YYrotation,shift={(0,4.6)},line width=.42 cm] \foreach \j in {0,5/8,-5/8} \draw (-5/4,\j)--(5/4,\j); \foreach \j in {5/8,-5/8} \draw[white,line width=.44 cm] (-5/48,\j)--(5/48,\j); \end{scope} % the summer trigram (the below-right corner) \begin{scope}[rotate=\YYrotation,shift={(0,-4.6)},line width=.42 cm] \foreach \j in {0,5/8,-5/8} \draw (-5/4,\j)--(5/4,\j); \foreach \j in {0,5/8,-5/8} \draw[white,line width=.44 cm] (-5/48,\j)--(5/48,\j); \end{scope} \end{tikzpicture} \end{document}

  • Use LaTeX to simulate old typewriter written texts
    by GregH on December 15, 2016 at 3:51 pm

    This question led to a new package: typewriter I'm giving my students an old exam and barely remembered to change the date at the top. A colleague and I joked about how long we could reuse the same exam, and it made me wonder if I could use LaTeX to create an exam that looked like it was written in 1963 on a typewriter. Here's what I'd like to see: Typewriter font even in math mode. (Several ways to accomplish this; is there a "best" way?) Slight inconsistencies in the printing of each letter. I attempt this below adapting code taken from here. Each word has a random vertical shift, though I'd like to see it reduced to each letter having its own vertical shift. Other typewriter-like irregularities would be great. It would be great if math-mode delimeters \left(, \right}, etc., can be created in a piece-meal fashion as they did in days of old. Fraction bars, tops of square-root symbols -- any horizontal line, really -- is made up of a series of en-dashes that don't quite match up. Here is what I've come up with so far: \documentclass[10pt]{article}% This is a document class providing more font size options \usepackage{graphicx} \usepackage{ifthen} \usepackage[textwidth=7.5in,textheight=9.5in]{geometry} \pagestyle{empty} % thanks to Bruno Le Floch: https://tex.stackexchange.com/q/9331/4012 % and in his comments to https://tex.stackexchange.com/a/29458/4012 \usepackage[first=-1,last=1]{lcg}% you can play around with these values \makeatletter \newcommand{\globalrand}{\rand\global\cr@nd\cr@nd} \makeatother \newcommand{\randomvshift}[1]{\globalrand\raisebox{\value{rand}pt}{#1}} %%% thanks to Martin Scharrer: https://tex.stackexchange.com/q/11598/4012 \makeatletter \def\typewriter#1{% \@typewriter#1 \@empty } \def\@typewriter#1 #2{% \randomvshift{#1}\space \ifx #2\@empty\else \expandafter\@typewriter \fi #2% } \makeatother \begin{document}\tt \typewriter{Math 101 Fall 1963} \begin{enumerate} \item \typewriter{$\frac{\texttt{d}}{\texttt{dx}}\texttt{(x)}^2$} \item \typewriter{State the Fundamental Theorem of Calculus.} \end{enumerate} \end{document}

  • Override hyphenation settings in caption
    by wrtlprnft on March 31, 2016 at 3:24 pm

    As tomorrow is April 1, I'd like to send a somewhat special interim version of my thesis to my supervisor. In the TeXbook, there is a chapter that is set up to make TeX fall in love with hyphenation. I like how it manages to hyphenate nearly every end-of line. However, applying this to my document, I ended up with something like this: \documentclass{article} \usepackage{graphicx,lipsum} \usepackage[hang,small,bf]{caption} % not loading this "fixes" my problem %\captionsetup{singlelinecheck=false} % this also causes the problem to disappear, but I like the singlelinecheck % handy commands from the TeXbook to apply all the best typographical rules regarding hyphenation \hyphenpenalty=-1000 \pretolerance=-1 \tolerance=1000 \doublehyphendemerits=-100000 \finalhyphendemerits=-100000 \begin{document} \begin{figure} \includegraphics[width=\textwidth,height=1cm]{example-image} \caption{Figure Caption that Should not Be Hyphenated} \end{figure} \lipsum[1] \end{document} Note how the text is nice and readable, but the caption is broken at every discetionary hyphen. Apparently, this is somehow related to the way caption checks whether the caption fits into a single line and should be centered. Also, if I don't load the package at all, the problem disappears. Is there a better way to fix this or to configure caption to use the normal hyphenation settings?

  • Given a list of primes, how can I plot π(x)?
    by Sean Allred on January 10, 2016 at 2:37 am

    Given an arbitrarily-long list of primes (or any sequence, I suppose), I'd like to calculate and plot the pairs (x, count of numbers in my list less than or equal to x) Bonus points for skipping the 'input a list of primes step' and using How to produce a list of prime numbers in LaTeX 🙂 But, you can assume that input is an ordered, comma-separated list (i.e. a clist) of prime integers. Of course, any input easier than that is also an option. MWE \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \begin{document} \begin{tikzpicture} \begin{axis}[ title={The prime counting function: $\pi(x)$}, xlabel=$x$, ylabel=$\pi(x)$, ] \addplot[only marks] table { x primes 0 0 % 0 is not prime; we have (0 primes ≤ 0) 1 0 % 1 is not prime; we have (0 primes ≤ 1) 2 1 % 2 is prime; we now have (1 prime ≤ 2) 3 2 % 3 is prime; we now have (2 primes ≤ 3) 4 2 % 4 is not prime; we have (2 primes ≤ 4) 5 3 % etc. 6 3 7 4 8 4 9 4 10 4 }; \end{axis} \end{tikzpicture} \end{document} Instead of providing π(x) manually like this, I'd like to just provide a list of primes in a text file or a clist. As always, brownie points for generality 🙂 Note that, per fun, I'm looking for a pure TeX solution – but all solutions (besides the trivial \includegraphics) are welcome 🙂

  • How can we make a pumpkin, jack-o-lantern, or other halloween spirit, ghoul, or skeleton?
    by A.Ellett on October 31, 2014 at 7:04 pm

    We have questions about Christmas trees and Hearts for Valentines but we have no questions that specialize in Halloween or Dia de los Muertos art. Here it goes: Using TikZ or PSTricks or any other of your favorite LaTeX tools, create pumpkins, ghouls, etc., appropriate to the season. I think multiple submissions should be fine provided different objects are created.

  • How compose an image from a specific text?
    by rigor on June 6, 2014 at 7:17 am

    I love playing around with ASCII art and, as you may know, there are tools to generate ASCII art from images, where the ASCII consists of those characters which will result in the best image, as this first picture shows: With the eye, you need ASCII characters with a lot of white (e.g. dots, commas, hyphens) to generate the brighter areas and characters with a lot of black (e.g. M, $) to generate darker areas. Now, what I want to achieve is being able to control the characters which make up the image. An example which is halfway there is the following image, where the story forms the shape of a raven. However, this raven is only flat, with no depth like the eye has. I would like to combine the examples with the eye and the raven. Would it be possible to achieve the same kind of effect in LaTeX either by using different shades of grey, or by using different sizes, for each individual character? So, for brighter areas, use a light grey or small black character, and for darker areas, use black and large characters. Does this make sense? Is it possible to achieve in an automatic way with LaTeX?

  • Nice scientific pictures show off
    by Thomas on February 5, 2014 at 8:40 am

    Task Show off your best scientific illustration ! The main purpose of this question is to share beautiful scientific pictures, preferably with an educational aspect. Content Your post must contain a nice picture and the associated code. One can post several pictures, but it must be done in different replies. Of course, it must be done with LaTeX & Friends : the post must start with a short sentence to present the language that you chose (TikZ, Asymptote ...) and the main packages that helped you to make the picture. Don't hesitate to add comments. Reward The satisfaction to share without expecting a reward 🙂 Ok ... 300 points reputation bounty for the best up-voted post until the 15th of Feb. Related links I'll contact Texample.net webmaster to see if he is interested to share the best illustrations, with the participant's agreement of course. Contest: Show Off Your Skillz in TeX & Friends

  • How can I make (some) $money$ out of my TeX skills?
    by jub0bs on September 27, 2013 at 12:46 am

    I by no means intend to stop contributing what I can to TeX.SE, but a recent experience begs the question... After helping a friend designing a flyer for a telecom company (for which she got decent remuneration), I find myself wondering whether there is a market for freelance TeX-related jobs, on which I could perhaps make some extra bucks for rainy days. As an amateur TeXnician with limited general knowledge of graphic design, but with a growing portfolio of decent-looking documents produced with TeX & friends, Who, if anyone, should I attempt to sell my TeX skills to? Would, say, a publishing company be interested? Or do they generally seek people with a much stronger background in TeX & friends than mine? If you are directly getting paid on account of your TeX skills, how did you get started? Note: I'm not sure whether this question is more appropriate on meta or on the main site. Feel free to migrate it, if necessary. It may be also be more suited as a community wiki, but I feel this isn't my call.

  • Showcase of optical illusions made with TeX/LaTeX/LuaTeX/ConTeXt
    by Gonzalo Medina on August 20, 2013 at 7:59 pm

    Optical illusions are fun, so I thought it would be a good idea to have a list of optical illusions designed using MetaPost, or PGF/TikZ, or PS-Tricks, or Asymptote. Each entry should display one optical illusion and the code necessary to produce it.

  • TeX assistance in writing hidden acrostics
    by mhelvens on June 27, 2013 at 7:04 pm

    Here's a fun challenge. Try to come up with (and code) techniques through which (La)TeX can help authors to incorporate acrostics in their writing. The definition from Wikipedia: An acrostic is a poem or other form of writing in which the first letter, syllable or word of each line, paragraph or other recurring feature in the text spells out a word or a message. The article contains a number of interesting examples. I don't expect TeX to do all the work (although that would earn you big bonus points), but I can imagine a number of ways in which it might assist: Allow the author to assert that a specific acrostic is present and generate a warning/error if it isn't. For the "first of every line" variety, subtly adjust line-breaking points to help. Optionally display the parts of the secret message that already 'line up' with different formatting. If you have other good ideas or, better yet, working code (doesn't have to be perfect), do share it with the rest of us! 🙂 Clarification of the Idea My initial purpose in posing this challenge was to collaboratively write a package that allows you, first and foremost, to embed hidden messages into a text. I agree that the question as posed was misleading. Ideally, the casual reader should not become aware that there was an acrostic present at all, so linebreaks should follow from the natural flow of text. That is the challenge for the author. The package I had in mind would allow the author to state what message he wants to hide and where. The interface could look something like this (using Davids example): \begin{acrostic}{1 letter}{every line}{TeXisfun} The trick is to let the system find the line breaks such that the expected letter starts each line. It is much easier if the source is XML. This main text is more or less relevant to the subject raised in the question. This text is far more interesting than boring Lipsum that you see in so many other answers on this site. You may find a distinct lack of TikZ in this answer, booktabs doesn't show up and nor does Lua. You will note how no special markup is needed: \TeX\ has a built- in ability to find the correct breaks. \end{acrostic} As mentioned above, LaTeX might then: Warn the author when his acrostic is broken and, to some degree, force the acrostic to appear by subtle manipulation of line-breaking penalties, or by some other clever tactic. That is the ideal scenario, and may be infeasible. I imagine it is easier to implement other solutions that are "almost as good", such as allowing the author to explicitly mark the relevant letters inside the full text, and letting LaTeX work off that. Collected Ideas from Comments and Answers For the "first of every line" variety: subtly adjust \textwidth to help. [by David Carlisle] For the "first of every line" variety: rather than maintain the natural flow of text and warn the author when the acrostic is broken, we can do the opposite and force the acrostic flush against the left margin and warn the author when the paragraph is too loose or tight. [by Steven B. Segletes] We'll need special treatment for acrostics spanning multiple sections or chapters. [by Ivan Andrus]

  • TeX – LaTeX in pop culture
    by f.boc on June 24, 2013 at 2:33 pm

    I'm doing a research on free-software references in movies, TV series, etc. Things like: "In Dr. House they use KDE as DE" or "Sheldon from the The Big Bang Theory uses Ubuntu." And the like. I'd love to include some TeX/LaTeX facts, but I've not managed to find any reference. Can you help me? Only restriction is that the movie/TV series etc. must be in English. I didn't know where to put this question so went for fun. Hope you don't mind this sort of questions, please forgive me if this is not allowed.

  • What is the most bizarre thing you have seen done with TeX
    by Xavier on March 25, 2013 at 6:49 pm

    I think the questions says it all! 🙂 By TeX, I mean any derivative of TeX as long as the code is clearly a derivative of TeX, i.e. that it could belong on TeX.SX (and not pure Lua for example). I'll give two answers myself so you see what I mean.

  • How to create a Caesar's encryption disk using LaTeX
    by Uwe Ziegenhagen on March 20, 2013 at 5:47 am

    How can I create a Caesar's encryption disk with LaTeX? I guess, the ultimate solution would take a arbitrary list of letters and calculate the spaces and angles for each letter automatically. So if I pass 4 letters to it, each space should have 90 degrees.

  • How can I draw an egg using TikZ?
    by Alex Grilo on September 26, 2012 at 12:36 pm

    I would like to draw an egg-format element, but I have only found ways of drawing ellipses.

  • How can I draw a cake using TikZ?
    by N.N. on January 28, 2012 at 4:35 pm

    It is always someone's birthday. I would like to use TikZ to draw a birthday cake. There are all sorts of cakes. What I would like is a cake that looks nice and tasty. Preferably a cake with lots of chocolate and vanilla custard. How can I draw this with TikZ? Here is something to start with: \documentclass{article} \usepackage{tikz} \usetikzlibrary{shapes} \newsavebox{\mycandle}% From https://tex.stackexchange.com/a/39211/5701 \savebox{\mycandle}{ \begin{tikzpicture}[scale=.1] \shade[top color=yellow,bottom color=red] (0,0) .. controls (1,.15) and (1,.3) .. (0,2.5) .. controls (-1,.3) and (-1,.15) .. (0,0); \fill[red!70!blue] (.4,0) rectangle (-.4,-5); \end{tikzpicture} } \begin{document} \begin{tikzpicture}[>=stealth, shape aspect=.5] \draw[fill=yellow!16] (0,-0.2) circle [x radius=1.59cm, y radius=0.29cm]; \node [cylinder,cylinder uses custom fill, cylinder end fill=yellow!6, cylinder body fill=yellow!12, shape border rotate=90, minimum width=3cm, minimum height=1.2cm, aspect=2.5, overlay, draw] {}; \foreach \candle in {(-0.32,1.05), (0.32,1.05), (1.2,0.9), (-1.2,0.9), (0.65,0.7), (-0.65,0.7)} \node at \candle {\usebox{\mycandle}}; \end{tikzpicture} \end{document} Oh, and apparently someone already made a pink cake but without providing a recipe.

  • How can we draw a Christmas tree with decorations, using TikZ?
    by Stefan Kottwitz on December 22, 2011 at 10:04 pm

    I would like to use TikZ for drawing a christmas tree. Here's a start, I used the lindenmayersystems library for drawing a tree: \documentclass{article} \usepackage{tikz} \usetikzlibrary{lindenmayersystems} \begin{document} \begin{tikzpicture} \draw [color=green!50!black, l-system={rule set={S -> [+++G][---G]TS, G -> +H[-G]L, H -> -G[+H]L, T -> TL, L -> [-FFF][+FFF]F}, step=4pt, angle=18, axiom=+++++SLFFF, order=11}] lindenmayer system -- cycle; \end{tikzpicture} \end{document} I found the tree in "The Science of fractal images" by Peitgen and Saupe. Who can help to decorate it? Or to draw another tree with Christmas decorations, such as tinsel garland (lametta), candles, baubles (Christmas balls), a tree topper? Perhaps add a shading to the green? For celebrating Christmas, I would like to put the tree on our blog, and on the TikZ example gallery.