Hot answers tagged

124

Merry Christmas everyone! \documentclass[11pt]{scrartcl} \usepackage[dvipsnames,svgnames]{xcolor} \usepackage{tikz} \usetikzlibrary{shapes,decorations.shapes} \newsavebox{\mycandle} \savebox{\mycandle}{ \begin{tikzpicture}[scale=.1] \shade[top color=yellow,bottom color=red] (0,0) .. controls (1,.2) and (1,.5) .. (0,2) .. controls (-1,.5) and (-1,.2) ...


116

Just in case the code isn't clear from behind the picture, here it is in full: \documentclass{article} \usepackage{listings} \usepackage{tikz} \usetikzlibrary{% lindenmayersystems, decorations.pathmorphing, decorations.markings, shapes.geometric, calc% } \tikzset{ tinsel/.style={ #1, rounded corners=10mm, ultra thin, decorate, ...


94

Another tree that can be decorated: Merry Christmas, everybody! \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \begin{document} % \begin{tikzpicture} \begin{axis}[ hide axis, clip=false, y domain=0:2*pi, samples=30,axis equal, view={45}{20}] \addplot3 [domain=0:4,surf,shader=flat,z buffer=sort,fill=green!50!brown, ...


86

Here's mine: \documentclass{article} \usepackage{tikz} \usetikzlibrary{scopes,svg.path,shapes.geometric,shadows} \begin{document} \begin{tikzpicture}[ mystar/.style={star, minimum size=2cm, star point ratio=2.5, shade, thick, line join=round, color=yellow!80!black, draw=red!20!black, top color=yellow!80!white, bottom color=yellow!60!black}, ...


73

While I'd normally second Will Robertson's comment, since TikZ is fantastic and worth learning, I think TikZ's overkill for this situation. I personally find its tree specification syntax bulkier than necessary. My preferred tool for the job is the qtree package (which is on CTAN, too, and is apparently included in both TeX Live and MikTeX). The package ...


61

Having been having fun with straight-edge-and-compass constructions (thanks to What is the simplest way to draw this triangle exactly?), I thought I'd try my hand at a Christmas tree constructed using straight-edge and compass. (The animated version is about 5Mb. I'll have to stick it somewhere other than imgur and link to it.) \documentclass[ % ...


57

Alan's answer works OK, but with the current version of Forest there is no need to define the edge path from scratch. Instead, we can use the edges library with the option forked edges. Moreover, we can eliminate growth parent anchor=east as it doesn't do anything (even in the old version of Forest), and we can use the parent and children anchors rather than ...


54

Previous solutions don't really use the fact that the tree can be completely generated procedurally (I think this is what the OP originally intended): And the picture will change every year! :) Tree for 2012: Tree for 2013: Tree for 2014: Tree for 2015: The solution added a new rule to the L-system, that collected some "good" points where ...


49

Here's a Christmas tree for 2015: \documentclass[tikz,border=5]{standalone} \usetikzlibrary{backgrounds,arrows.meta} \pgfdeclarelayer{foreground} \pgfdeclarelayer{before-background} \pgfsetlayers{background,before-background,main,foreground} \usepackage{luacode} \begin{luacode*} floor = math.floor ceil = math.ceil Maze = {} Maze.__index = Maze Maze.NORTH = ...


46

{\let~\catcode~`A0 AgdefAs.#1.{Acsname#1Aendcsname}AdefAq#1#2#3#4#5#6#7#8#9{%####################### AdefAy##1###1##3##4##5###3###2##8##9{AdefAw####1#####1####3####4####5#####3#####2####8####9{%####### AdefAz########1#########1########3########4########5#########3#########2########8########9{Aegroup%# ...


41

This is not very difficult to do with forest. The following example should get you started. \documentclass{article} \usepackage{forest} \begin{document} \begin{forest}for tree={ grow=east parent anchor=east, child anchor=west, math content, edge path={\noexpand\path[\forestoption{edge},->, >={latex}] (!u.parent anchor) ...


37

I have learned a couple of new things in TikZ and created an own minimalistic version loosely based on Altermundus' first creation (and a beautiful one it is). Hopefully he does not mind. Merry Christmas to all of you! \documentclass[border=2mm]{standalone} \usepackage[dvipsnames]{xcolor} \usepackage{tikz} \usetikzlibrary{shapes,decorations.shapes} ...


34

Merry Christmast everyone! \documentclass{beamer} \usepackage{graphicx} \usepackage{tikz} \usetikzlibrary{shapes.geometric} \usepackage{animate} \usepackage{hyperref} \hypersetup{pdfpagemode=FullScreen} \usepackage{ifthen} \newcounter{mycount} \setcounter{mycount}{0} \begin{document} \begin{frame}[fragile]{} \begin{center} \resizebox{5cm}{!}{% ...


31

As already mentioned, the only real solution is to define a new shape, with correct border anchors. So, here it is: rectangle with rounded corners. The radius of the corner is controllable by /pgf/rectangle corner radius. \documentclass{article} \usepackage{tikz} \usetikzlibrary{intersections} \begin{document} \makeatletter \pgfkeys{/pgf/.cd, ...


30

We are still within the 12 days of Christmas and the wise men have not yet arrived bearing gifts, so I trust that I do not arrive too late. I wondered... If we have trees, why not a forest? There is, of course, no reason whatsoever to draw a Christmas tree using forest.... Nadolig Llawen! \PassOptionsToPackage{rgb,x11names,svgnames}{xcolor} ...


28

Here's one option using the powerful forest package; since its built upon TikZ the customization possibilities are enormous. For example one can easily simulate the style produced by dirtree: \documentclass[border=5pt]{standalone} \usepackage{forest} \begin{document} \begin{forest} for tree={ font=\ttfamily, grow'=0, child anchor=west, ...


27

The dirtree package is your friend.


25

I just came across this thanks to the duplicate at Vertical trees with TikZ. The following code seems to work, though I will admit to not testing it fully and making up the numbers so that it just works. Let's start with some output: Here's the code: \documentclass[border=10]{standalone} \usepackage{tikz} \makeatletter \newcount\dirtree@lvl ...


25

The trees library provides a grow cyclic key/growth function. A few styles for the levels and a few child foreach path operators give you the following. Code \documentclass[tikz]{standalone} \usetikzlibrary{trees} \begin{document} \begin{tikzpicture}[ grow cyclic, level distance=1cm, level/.style={ level distance/.expanded=\ifnum#1>1 ...


24

Refer to Section 18.4 Specifying Options for Trees and Children of the pgfmanual. Using sibling distance, you can solve the problem (use the values that best suit your needs): \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[every node/.style={circle,draw},level 1/.style={sibling distance=30mm},level 2/.style={sibling ...


23

I am going to put in a plea on behalf of forest. Although forest is extremely flexible and powerful, it can also be used very simply. Like qtree, it uses a simple, concise syntax which 'reads like a tree' but I found forest's syntax a bit easier to learn. (However, this may be because I learnt qtree first.) Like tikz-qtree, it gives you all the power of TikZ ...


21

This is not commonly the way trees are represented in the linguistic literature, so none of the regular tree drawing packages (qtree and tikz-qtree) do this by default. Specifically, the way trees are drawn in the linguistics literature, the terminal nodes are not drawn at the same level (i.e. with the words along a baseline and the tree growing up from ...


20

Here are two concepts doing it with TikZ. The first one doesn't draw enough lines, the second one draws too many. I guess one needs counters for each level. Those counters would be increased if the same level occurs again and draw a line to it, while they would reset when a higher level is encounterd, e.g. like one could principally do with ...


19

Just a tree with extremely ugly code(I do not know how to do it corectly?! -ovelay and center): \documentclass{article} \usepackage{overpic} \usepackage{graphicx} \begin{document} \begin{overpic}[unit=1cm, width=8cm, height=12cm]{ttt} \put(14.5,0){\includegraphics[width=4cm,height=12cm]{ttt}} \put(23,0){\includegraphics[width=1.5cm,height=12cm]{ttt}} ...


17

Here's another option using forest to illustrate some other of its features: \documentclass{standalone} \usepackage{tabularx} \usepackage{forest} \usetikzlibrary{shapes.geometric} % comment out the following four lines if the Helvet Neue font are not available: \usepackage{fontspec} \newfontfamily\namefont[]{Helvetica Neue Condensed Bold} ...


16

You can do this sort of tree easily with the tikz-qtree package: In the code below, the labels are created using a tree with branches that are not actually drawn (using a style blank which sets [draw=none]). This ensures that they line up with the levels of the main tree. By putting two trees as nodes in a matrix we achieve a reasonable separation between ...


16

Get used to this error, it's a common one with tikz-qtree: tikz-qtree requires a space before a node's contents and its closing ]. So you need to insert some spaces before each ] in your tree. \Tree [.{Boolean Groups} [.{Abelian Groups} [.Groups ] % Here ] [.{Class 3} [.{Class 5} ] % Here etc. [.{Class 1} ] ...


15

tikz-qtree is an awesome package for more convenient tree drawing in tikz.


15

The modifications suggested in this answer have now been subsumed into the tikz-qtree package (version 1.2 or higher). See the documentation for details on how to accomplish this with the latest version. (This happened in April 2012.) Looking through the code for tikz-qtree then it appears* that it completely reimplements the tree-planting routines. ...


15

Using forest: \documentclass{article} \usepackage{forest} \newcommand\mytable[5]{% #1\\ \begin{tabular}[t]{*{3}{|c}|} \hline & T1 & T2 \\ \hline T1 & #2 & #3 \\ \hline T2 & #4 & #5 \\ \hline \end{tabular}% } \begin{document} \begin{forest} for tree={parent anchor=south, child anchor=north,l=2cm,edge={->}}, for descendants={text ...



Only top voted, non community-wiki answers of a minimum length are eligible