-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo-tikz.tex
155 lines (125 loc) · 4.17 KB
/
demo-tikz.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
% A test file for the module "diagtikz.lua" of dednat6.
% This file: http://angg.twu.net/dednat6/demo-tikz.tex.html
% http://angg.twu.net/dednat6/demo-tikz.tex
% (find-dednat6 "demo-tikz.tex")
% Output: http://angg.twu.net/dednat6/demo-tikz.pdf
%
% (defun c () (interactive) (find-dednat6sh "lualatex -record demo-tikz.tex"))
% (defun d () (interactive) (find-pdf-page "~/dednat6/demo-tikz.pdf"))
% (defun e () (interactive) (find-dednat6 "demo-tikz.tex"))
% (defun u () (interactive) (find-latex-upload-links "demo-tikz"))
% (find-pdf-page "~/dednat6/demo-tikz.pdf")
% http://angg.twu.net/dednat6/demo-tikz.pdf
%
\documentclass[oneside]{article}
\usepackage[colorlinks,citecolor=DarkRed,urlcolor=DarkRed]{hyperref} % (find-es "tex" "hyperref")
\usepackage[x11names,svgnames]{xcolor} % (find-es "tex" "xcolor")
%
%\usepackage{proof} % For derivation trees ("%:" lines)
\input diagxy % For 2D diagrams ("%D" lines)
\xyoption{curve} % For the ".curve=" feature in 2D diagrams
%
\usepackage{tikz}
%
\begin{document}
\catcode`\^^J=10 % (find-es "luatex" "spurious-omega")
\directlua{dofile "dednat6load.lua"} % (find-dednat6 "dednat6load.lua")
\def\defdiagtikz#1#2{\expandafter\def\csname diagtikz-#1\endcsname{#2}}
\def\ifdiagtikzundefined#1{\expandafter\ifx\csname diagtikz-#1\endcsname\relax}
\def\diagtikz#1{\ifdiagtikzundefined{#1}
\errmessage{UNDEFINED DIAGTIKZ: #1}
\else
\csname diagtikz-#1\endcsname
\fi
}
% A poor man's "\verb"
\def\co#1{{%
\def\\{\char92}%
\def\%{\char37}%
\tt#1%
}}
\def\qco#1{`\co{#1}'}
\title{Dednat6: a demo for diagtikz.lua}
\author{Eduardo Ochs}
\date{}
\maketitle
Dednat6 can generate Tikz code for diagrams instead of diagxy code,
but the current support for Tikz is a currently a very minimal
prototype that only supports a few kinds of arrows --- namely
\qco{->}, \qco{|->}, and \qco{=>} ---, it ignores the modifers for
labels, placement, slides, and curve, and it generates Tikz code that
looks awful when rendered... the two diagrams below were generated
from \qco{\%D}-blocks that were almost identical, but the first one
used \qco{diagram test-diagxy} and \qco{enddiagram} and the second one
used \qco{tikzdiagram test-tikz} and \qco{endtikzdiagram}.
%L require "diagtikz"
%
%D diagram test-diagxy
%D 2Dx 100 +40
%D 2D 100 A --> B
%D 2D |
%D 2D +30 C
%D 2D
%D (( A B -> .plabel= a foo
%D B C => .plabel= r bar
%D A C |-> .plabel= m plic
%D ))
%D enddiagram
%D
%D tikzdiagram test-tikz
%D 2Dx 100 +40
%D 2D 100 A --> B
%D 2D |
%D 2D +30 C
%D 2D
%D (( A B -> .plabel= a foo
%D B C => .plabel= r bar
%D A C |-> .plabel= m plic
%D ))
%D endtikzdiagram
\pu
%% The code above generates this:
%
% \defdiag{test-diagxy}{
% \morphism(0,0)|a|/->/<600,0>[{A}`{B};{foo}]
% \morphism(600,0)|r|/=>/<0,-450>[{B}`{C};{bar}]
% \morphism(0,0)|m|/|->/<600,-450>[{A}`{C};{plic}]
% }
% \defdiagtikz{test-tikz}{
% \begin{tikzpicture}
% \node (100 100) at (0.0,0.0) {$A$};
% \node (140 100) at (2.0,0.0) {$B$};
% \node (140 130) at (2.0,-1.5) {$C$};
% \draw [->] (100 100) -- (140 100);
% \draw [{}-{>},double] (140 100) -- (140 130);
% \draw [{|}-{>}] (100 100) -- (140 130);
% \end{tikzpicture}}
$$\diag{test-diagxy}
\quad
\diagtikz{test-tikz}
$$
\bigskip
The Tikz code generated for the second diagrams is:
\begin{verbatim}
\defdiagtikz{test-tikz}{
\begin{tikzpicture}
\node (100 100) at (0.0,0.0) {$A$};
\node (140 100) at (2.0,0.0) {$B$};
\node (140 130) at (2.0,-1.5) {$C$};
\draw [->] (100 100) -- (140 100);
\draw [{}-{>},double] (140 100) -- (140 130);
\draw [{|}-{>}] (100 100) -- (140 130);
\end{tikzpicture}}
\end{verbatim}
The problem is that I know very little Tikz! If you know how to make
the Tikz code above better --- how to fix the double arrow, how to add
the labels, whatever --- please get in touch!
\bigskip
The source of this file is here:
% \medskip
\url{http://angg.twu.net/dednat6/demo-tikz.tex.html}
\url{http://angg.twu.net/dednat6/demo-tikz.tex}
\end{document}
% Local Variables:
% coding: utf-8-unix
% End: