-
Notifications
You must be signed in to change notification settings - Fork 19
/
timeline_8pane.tex
311 lines (270 loc) · 10.3 KB
/
timeline_8pane.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
\documentclass{article}
% Document Packages
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=cyan,
}
\usepackage{geometry}
\geometry{
a4paper,
noheadfoot=true,
left=1.0in,
right=1.0in,
top=1.0in,
bottom=1.0in,
}
% Tikz and Figure Packages
\usepackage{caption}
\usepackage{amsmath} % aligned env
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Titles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Latex Tikz Examples\\Model Timeline with Dynamically Sized Panes and Text Blocks \\ Eight Dynamic Panes and Four Dynamic Text Blocks}
\author{\href{https://fanwangecon.github.io/}{Fan Wang}\thanks{https://fanwangecon.github.io, repository: \href{https://fanwangecon.github.io/Tex4Econ/}{Tex4Econ}}}
\date{\today}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% A. Define Core Frame
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\tikzframeeight}[7]{
%%% 1. Define Figure Width and Height as Ratio of Page Width and Height
% param 7 rescales, set same as every node/.style={scale=#7}
\def\fgiw{#1*\textwidth*#7}
\def\fgih{#2*\textheight*#7}
%%% 2. Cut Figure into Four Quadrants
% fgiwm: breaks the left and right quadrants
% fgihm: breaks the top and bottom quadrants
\def\fgiwm{#3*\fgiw}
\def\fgihm{#4*\fgih}
%%% 3. Divide each quadrant into two parts, 8 parts
% each quadrant now has small left edge or small right edge
% fgile: break a small piece off left quadrant
% fgire: break a small piece off left quadrant
\def\fgile{#5*\fgiw}
\def\fgire{#6*\fgiw}
%%% Commonly Used Non-Parameters
% left pane horizontal middle point, align horizontally middle pane
\def\fgiwlm{\fgile*0.5 + \fgiwm*0.5}
% right pane horizontal middle point, align horizontally middle in pane
\def\fgiwrm{\fgiwm*0.5 + \fgire*0.5}
% fgihtb: figure internal height top pane bottom
% vertically bottom 10 percent space of top pane space
\def\fgihtb{\fgihm + \fgih*0.085 - \fgihm*0.085}
% fgihtm: figure internal height top and bottom pane middle height
% top panel vertical middle spot, align vertically center
\def\fgihtm{\fgihm*0.5 + \fgih*0.5}
% bottom panel vertical middle spot, align vertically center
\def\fgihbm{\fgihm*0.5}
% There is a flow line on top, limited text
% three parts, left prior, right after, middle current.
% current in two parts, shock realization and choices.
% In top part, span charts, simple text
% in bottom part, sufficient height to allow for detailed text
% descriptions.
% Bottom and top lines
\draw [dotted] (0, \fgih) -- (\fgiw, \fgih);
\draw [dotted] (0, 0 ) -- (\fgiw, 0 );
% Left and right lines
\draw [dotted] (0, 0) -- (0, \fgih);
\draw [dotted] (\fgiw, 0) -- (\fgiw, \fgih);
% verticle middle line
\draw [dotted] (\fgiwm, 0) -- (\fgiwm, \fgih);
% horizontal middle line (divide text and flow)
\draw [solid] (0, \fgihm) -- (\fgiw, \fgihm);
% left border last period
\draw[dashed] (\fgile, 0 ) -- (\fgile, \fgih);
% right border next period
\draw[dashed] (\fgire, 0 ) -- (\fgire, \fgih);
% Heading for the left-most, right-most and center areas
\node[align=center] at (0.5*\fgile, 0.900*\fgih) {last\\period};
\node[align=center] at (0.5*\fgiw, 0.900*\fgih) {current period};
\node[align=center] at (0.5*\fgire + 0.5*\fgiw, 0.900*\fgih) {next\\period};
% Sub-label for the left and right part of center pane
\node[align=center] at (\fgiwlm, \fgihtb) {shocks};
\node[align=center] at (\fgiwrm, \fgihtb) {asset choices};
% Arrows in top pane, between left border center, center left and right and center to right border
\draw [->, line width=0.25mm] (\fgile-0.2*\fgile, \fgihtm) -- (\fgile+0.2*\fgile, \fgihtm);
\draw [->, line width=0.25mm] (\fgiwm-0.2*\fgile, \fgihtm) -- (\fgiwm+0.2*\fgile, \fgihtm);
\draw [->, line width=0.25mm] (\fgire-0.2*\fgile, \fgihtm) -- (\fgire+0.2*\fgile, \fgihtm);
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% B. Define text block
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\textA}{choose \\ $k, b$}
\newcommand{\textB}{$\Gamma\left(k,b,\epsilon\right)$}
\newcommand{\textC}{$\begin{aligned}c &= \Gamma\cdot\phi\\k &= \Gamma\cdot\phi\cdot\theta\\b &= \Gamma\cdot\phi\cdot\left(1-\theta\right)\end{aligned}$}
\newcommand{\textD}{draw \\$\epsilon^{\prime}$ shock}
\newcommand{\tikztextblock}[4]{
% #1=choose \\ $k, b$
% #2=$\Gamma\left(k,b,\epsilon\right)$
% #3=$\begin{aligned}c &= \Gamma\cdot\phi\\k &= \Gamma\cdot\phi\cdot\theta\\b &= \Gamma\cdot\phi\cdot\left(1-\theta\right)\end{aligned}$
% #4=draw \\$\epsilon^{\prime}$ shock
% 2. Text
\node[align=center] (A) at (0.5*\fgile, \fgihtm)
{#1};
\node[align=center] (B) at (\fgiwlm, \fgihbm)
{#2};
\node[align=center] (C) at (\fgiwrm, \fgihbm)
{#3};
\node[align=center] (D) at (0.5*\fgire + 0.5*\fgiw, \fgihtm)
{#4};
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% C. Define Spaning Continuous Choices and Discrete Choices
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% C.1 Continuous Shocks
\tikzset{
% Two node styles for game trees: solid and hollow
solid node/.style={circle,draw,inner sep=1.5,fill=black},
hollow node/.style={circle,draw,inner sep=1.5,fill=white}
}
\newcommand{\shkspan}[3]{
\def\famm{\fgiw*#3}
\tikzstyle{level 1}=[level distance=\famm,sibling distance=\famm]
\node(0)[solid node, align=center, % solid node gives fist (left to right) black dot
label=left:{
$\textcolor{black}{\epsilon}$
}] at (#1, #2) {}
[grow=right]
child{
[black] node(31)[]{}
edge from parent
node[sloped, below, black]{}
}
child{
edge from parent
[draw=none]
}
child{
[red] node(33)[]{}
edge from parent
node[sloped, above, black]{}
};
\draw[dashed, bend right]
(31) to (33);
}
%%% C.2 Continuous Spanning Choices
\newcommand{\ctsspans}[3]{
\def\famm{\fgiw*#3}
\tikzstyle{level 1}=[level distance=\famm,sibling distance=\famm]
\tikzstyle{level 2}=[level distance=\famm,sibling distance=\famm]
\node[solid node, align=center, % solid node gives fist (left to right) black dot
label=left:{
$\textcolor{black}{\phi}$
}] at (#1, #2) {}
[grow=right]
child{
[black] node(11)[]{}
edge from parent
node[sloped, below, black]{$\phi=0$}
}
child{
[grow=right]
% The starting node for theta
node(12)[solid node, xshift=9, yshift=0, % solid node gives second (left to right) black dot
label=left:{
$\theta$
}]{}
% Draw the theta branches
child{
[red] node(21)[]{}
edge from parent
node[sloped, below, black]{$\theta=0$}
}
child{
[white] node(22)[xshift=16, yshift=0]{}
edge from parent
[draw=none]
}
child{
[black] node(23)[]{}
edge from parent
node[sloped, above, black]{$\theta=1$}
}
edge from parent
[draw=none]
}
child{
[red] node(13)[]{}
edge from parent
node[sloped, above, black]{$\phi=1$}
};
\draw[dashed, bend right]
(11) to (13);
\draw[dashed, bend right]
(21) to (23);
}
\begin{document}
\maketitle
Generate a eight pane model timeline tikz structure. The proportional sizes of each pane is determined by parameters, and are porportional to pages. The 8 pane tables have 7 parameters that auto shift the figures.
\section{Empty Frames with Eight Panes}
The idea is that the top panes would show overall model timeline. The bottomw below horizontal line spaces could have equations that provide more information sufficiently about what is happening in timeline above.
\begin{center}
\begin{tikzpicture}[scale=1.0, every node/.style={scale=1.0}]
\tikzframeeight{1}{0.25}{0.5}{0.35}{0.125}{0.875}{1.0}
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tikzpicture}[scale=1.0, every node/.style={scale=0.5}]
\tikzframeeight{1}{0.25}{0.6}{0.35}{0.125}{0.875}{0.5}
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tikzpicture}[scale=1.0, every node/.style={scale=0.75}]
\tikzframeeight{1}{0.20}{0.2}{0.50}{0.125}{0.875}{0.75}
\end{tikzpicture}
\end{center}
\pagebreak
\section{Eight Dynamic Panes and Four Dynamic Text Blocks}
Now in addition to the frame structure, add in text, the texts are dynamically controlled with textblocks. The positions are dynamically sized automatically. Text contents could change.
\begin{center}
\begin{tikzpicture}[scale=1.0, every node/.style={scale=1.0}]
\tikzframeeight{1}{0.25}{0.5}{0.35}{0.125}{0.875}{1.0}
\tikztextblock{\textA}{\textB}{\textC}{\textD}
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tikzpicture}[scale=1.0, every node/.style={scale=0.5}]
\tikzframeeight{1}{0.25}{0.6}{0.35}{0.125}{0.875}{0.5}
\tikztextblock{hello \\ there}{block two}{this is third}{now \\ fourth \\ text \\ block}
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tikzpicture}[scale=1.0, every node/.style={scale=0.75}]
\tikzframeeight{1}{0.20}{0.2}{0.50}{0.125}{0.875}{0.75}
\tikztextblock{$k$}{$\Gamma$}{$\Lambda$ \\ here you go \\ yes works}{$\epsilon$}
\end{tikzpicture}
\end{center}
\pagebreak
\section{Eight Dynamic Panes and Four Dynamic Text Blocks and Spanning Choices}
Eight Pane, dynamic panes, and also dynamically positioned spanning choices.
\begin{center}
\begin{tikzpicture}[scale=1.0, every node/.style={scale=1.0}]
\tikzframeeight{1}{0.25}{0.5}{0.35}{0.125}{0.875}{1.0}
\tikztextblock{\textA}{\textB}{\textC}{\textD}
\shkspan{\fgile*0.600 + \fgiwm*0.400}{\fgihtm}{0.065}
\ctsspans{\fgiwm*0.675 + \fgire*0.325}{\fgihtm}{0.065}
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tikzpicture}[scale=1.0, every node/.style={scale=0.5}]
\tikzframeeight{1}{0.25}{0.6}{0.35}{0.125}{0.875}{0.5}
\tikztextblock{hello \\ there}{block two}{this is third}{now \\ fourth \\ text \\ block}
\shkspan{\fgile*0.600 + \fgiwm*0.400}{\fgihtm}{0.05}
\ctsspans{\fgiwm*0.675 + \fgire*0.325}{\fgihtm}{0.05}
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tikzpicture}[scale=1.0, every node/.style={scale=0.75}]
\tikzframeeight{1}{0.20}{0.2}{0.50}{0.125}{0.875}{0.75}
\tikztextblock{$k$}{$\Gamma$}{$\Lambda$ \\ here you go \\ yes works}{$\epsilon$}
\shkspan{\fgile*0.600 + \fgiwm*0.400}{\fgihtm}{0.05}
\ctsspans{\fgiwm*0.675 + \fgire*0.325}{\fgihtm}{0.05}
\end{tikzpicture}
\end{center}
\pagebreak
\end{document}