File: special-theme-elements.md

package info (click to toggle)
sphinx-book-theme 1.1.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,104 kB
  • sloc: python: 1,302; javascript: 170; makefile: 56; sh: 8
file content (337 lines) | stat: -rw-r--r-- 7,128 bytes parent folder | download | duplicates (2)
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
---
jupytext:
  text_representation:
    extension: .md
    format_name: myst
    format_version: '0.8'
    jupytext_version: 1.4.1+dev
kernelspec:
  display_name: Python 3
  language: python
  name: python3

execution:
  timeout: -1
---

# Theme-specific elements

This page contains a number of reference elements to see how they look in this
theme. The information is not meant to be easy to read or understand, just browse
through and see how things look!

## Full-width elements

### Code cells

```{code-cell} ipython3
:tags: [remove_cell]

# Generate some code that we'll use later on in the page
import numpy as np
import matplotlib.pyplot as plt

np.random.seed(0)

square = np.random.randn(100, 100)
wide = np.random.randn(100, 1000)
```

```{code-cell} ipython3
:tags: [full_width]

## A full-width square figure
fig, ax = plt.subplots()
ax.imshow(square)
plt.show()
```

```{code-cell} ipython3
:tags: [full_width]

## A full-width wide figure
fig, ax = plt.subplots()
ax.imshow(wide)
plt.show()
```

```{code-cell} ipython3
# Now here's the same figure at regular width
fig, ax = plt.subplots()
ax.imshow(wide)
plt.show()
```

### Markdown

```{container} full-width

This is some markdown that should be shown at full width.

![](../images/cool.jpg)

:::{note}
Here's a full-width admonition!
:::

```

### Mathematics

\begin{equation*}
  \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
\end{equation*}

$$
  \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
$$


```{math}
:label: my_label
w_{t+1} = (1 + r_{t+1}) s(w_t) + y_{t+1}
```

Link to above: {eq}`my_label`

```{math}
:label: my_label2
w_{t+1} = (1 + r_{t+1}) s(w_t) + y_{t+1} \\
w_{t+1} = (1 + r_{t+1}) s(w_t) + y_{t+1} \\
w_{t+1} = (1 + r_{t+1}) s(w_t) + y_{t+1}
```

Link to above: {eq}`my_label2`

* $$
\mathcal{O}(f) = \{ g |
    \exists c > 0,
    \exists n_0 \in \mathbb{N}_0,
    \forall n \geq n_0
        :
    [g(n) \leq c \cdot f(n)]\}$$

A really long math equation

$$
\begin{align}
\mathrm{SetConv} \left( \{(x^{c},y^{c})\}_{c=1}^{C} \right)(x) \left( \{(x^{c},y^{c})\}_{c=1}^{C} \right)(x) \left( \{(x^{c},y^{c})\}_{c=1}^{C} \right)(x)
&= \sum_{c=1}^{C} y^{(c)} w_{\theta} \left( x - x^{(c)} \right)  \sum_{c=1}^{C} y^{(c)} w_{\theta} \left( x - x^{(c)} \right) \sum_{c=1}^{C} y^{(c)} w_{\theta} \left( x - x^{(c)} \right)\\
&= \left( y^{(c')} w_{\theta} \left( x - x^{(c')} \right) \right) + \sum_{c \neq c'}  y^{(c)} w_{\theta} \left( x - x^{(c)} \right) \\
&= 0 + \sum_{c \neq c'}  y^{(c)} w_{\theta} \left( x - x^{(c)} \right)
\end{align}
$$

Full width equations work

```{math}
:class: full-width

\begin{align}
\mathrm{SetConv} \left( \{(x^{c},y^{c})\}_{c=1}^{C} \right)(x) \left( \{(x^{c},y^{c})\}_{c=1}^{C} \right)(x) \left( \{(x^{c},y^{c})\}_{c=1}^{C} \right)(x)
&= \sum_{c=1}^{C} y^{(c)} w_{\theta} \left( x - x^{(c)} \right)  \sum_{c=1}^{C} y^{(c)} w_{\theta} \left( x - x^{(c)} \right) \sum_{c=1}^{C} y^{(c)} w_{\theta} \left( x - x^{(c)} \right)\\
&= \left( y^{(c')} w_{\theta} \left( x - x^{(c')} \right) \right) + \sum_{c \neq c'}  y^{(c)} w_{\theta} \left( x - x^{(c)} \right) \\
&= 0 + \sum_{c \neq c'}  y^{(c)} w_{\theta} \left( x - x^{(c)} \right)
\end{align}
```

+++

## Margins

+++

Margin content can include all kinds of things, such as code blocks:

````{margin} Code blocks in margins
```python
print("here is some python")
```
````

as well as admonitions and images:

````{margin} **Notes in margins**
```{note}
Wow, a note with an image in a margin!
![](../images/cool.jpg)
```
````

### Margin under lower level shouldn't have different left-alignment

````{margin} **Notes in margins**
```{note}
Wow, a note with an image in a margin!
![](../images/cool.jpg)
```
````

### Margins with toggle buttons

Here's some margin content, let's see how it interacts w/ the toggle button

```{margin} My margin
Here's my margin content
```

Here's a toggleable note:

```{note}
:class: toggle
My note
```

### Margins with full-width content

```{note}
:class: tag_fullwidth
This is my test
```

Let's see what happens

```{code-cell} ipython3
:tags: [margin]

## code cell in the margin with output
fig, ax = plt.subplots()
ax.imshow(wide)
plt.show()
```

````{margin}

Markdown cell with code in margin

```python
a = 2
b = 3
def aplusb(a, b):
    return a+b
```
and now r

```r
a <- 2
b <- 4
a+b
```

how does it look?

Markdown cell with images in sidebar

![](../images/cool.jpg)

````
+++

### More content after the margin content

This is extra content after the margins to see if cells overlap and such.
Also to make sure you can still interact with the margin content.
This is extra content after the margins to see if cells overlap and such.
Also to make sure you can still interact with the margin content.

```python
a = 2
```

This is extra content after the margins to see if cells overlap and such.
Also to make sure you can still interact with the margin content.
This is extra content after the margins to see if cells overlap and such.
Also to make sure you can still interact with the margin content.
This is extra content after the margins to see if cells overlap and such.
Also to make sure you can still interact with the margin content.

### Figures with margin captions

The `margin-caption` class should cause a figure's caption to pop out to the right.

```{figure} ../images/cool.jpg
---
width: 60%
figclass: margin-caption
alt: My figure text
name: reference-margin-fig
---
And here is my figure caption, if you look to the left, you can see that COOL is in big red letters. But you probably already noticed that, really I am just taking up space to see how the margin caption looks like when it is really long :-).
```

:::{note}
:class: margin
This note should not overlap with the margin caption!
:::

Entire figures in the margin:

```{figure} ../images/cool.jpg
---
width: 60%
figclass: margin
alt: My figure text
---
This figure should be entirely in the margin.
```

## Sidenotes and marginnotes

Here's a sentence[^sn1] with multiple [^sn2] sidenotes.

[^sn1]: Test sidenote 1.
[^sn2]: Test sidenote 2.

Here's a sentence[^mn1] with multiple marginnotes[^mn2].

[^mn1]: {-} Test marginnote 1.
[^mn2]: {-} Test marginnote 2.


Sidenotes inside of admonitions should behave the same:

:::{note}
An admonition with a sidenote defined in the admonition[^snam1] and another defined outside of the admonition [^snam2].

[^snam1]: Sidenote defined in the admonition.

:::

[^snam2]: Sidenote defined outside the admonition.


## Nested admonitions

These aren't theme-specific, but we still show below to make sure they work.

::::{note} Here's a note!

```{tip} And a tip!
```

::::

## MyST Markdown elements

Here are a few design elements to show off MyST Markdown.

### Table alignment

To ensure that markdown alignment is rendered properly.

| Default Header | Left Align | Right Align | Center Align |
| -------------- | :--------- | ----------: | :----------: |
| Cell 1 | Cell 2 | Cell 3 | Cell 4 |
| Cell 1 | Cell 2 | Cell 3 | Cell 4 |

### List table width

Testing list tables take width as expected.

```{list-table}
:width: 100%
* - a
  - b
* - c
  - d
```