You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -21,19 +21,20 @@ There are a few content blocks that are unique to this theme.
21
21
22
22
Here is what quotations and epigraphs look like in `sphinx-book-theme`:
23
23
24
-
A quote with no attribution:
25
-
24
+
```{example} Default markdown quotes
26
25
> Here's my quote, it's pretty neat.
27
26
> I wonder how many lines I can create with
28
27
> a single stream-of-consciousness quote.
29
28
> I could try to add a list of ideas to talk about.
30
29
> I suppose I could just keep going on forever,
31
30
> but I'll stop here.
31
+
```
32
32
33
33
Sometimes you'd like to draw more attention to a quote. To do so, use the `{epigraph}` directive.
34
34
Below is an epigraph, click the button to the right of it to show the code that was used
35
35
to generate it:
36
36
37
+
````{example} A basic epigraph
37
38
```{epigraph}
38
39
Here's my quote, it's pretty neat.
39
40
I wonder how many lines I can create with
@@ -42,36 +43,12 @@ I could try to add a list of ideas to talk about.
42
43
I suppose I could just keep going on forever,
43
44
but I'll stop here.
44
45
```
45
-
46
-
`````{toggle}
47
46
````
48
-
```{epigraph}
49
-
Here's my quote, it's pretty neat.
50
-
I wonder how many lines I can create with
51
-
a single stream-of-consciousness quote.
52
-
I could try to add a list of ideas to talk about.
53
-
I suppose I could just keep going on forever,
54
-
but I'll stop here.
55
-
```
56
-
````
57
-
`````
58
47
59
48
You can also add an attribution to epigraphs by adding a blank line,
60
49
followed by a line that starts with `--`. This will be renderered like so:
61
50
62
-
```{epigraph}
63
-
Here's my quote, it's pretty neat.
64
-
I wonder how many lines I can create with
65
-
a single stream-of-consciousness quote.
66
-
I could try to add a list of ideas to talk about.
67
-
I suppose I could just keep going on forever,
68
-
but I'll stop here.
69
-
70
-
-- Jo the Jovyan, *[the jupyter book docs](https://jupyterbook.org)*
71
-
```
72
-
73
-
`````{toggle}
74
-
````
51
+
````{example} Epigraphs with attribution
75
52
```{epigraph}
76
53
Here's my quote, it's pretty neat.
77
54
I wonder how many lines I can create with
@@ -83,65 +60,49 @@ but I'll stop here.
83
60
-- Jo the Jovyan, *[the jupyter book docs](https://jupyterbook.org)*
84
61
```
85
62
````
86
-
`````
87
63
88
-
## Sidebars
89
-
90
-
There are two different kinds of sidebar-like content in `sphinx-book-theme`,
91
-
typical `{sidebar}` directives, as well as a theme-specific `{margin}` directive.
92
-
This section covers both. Both allow you to place extra content
93
-
separately from your main content.
94
-
95
-
```{tip}
96
-
Sidebar content will generally overlap with the white space where your site's
97
-
table of contents lives. When the reader scrolls sidebar content into view, the
98
-
right TOC should hide itself automatically.
99
-
```
100
-
101
-
### Margin content
64
+
## Margin content
102
65
103
66
You can specify content that should exist in the right margin. This will behave
104
67
like a regular sidebar until the screen hits a certain width, at which point this
105
68
content will "pop out" to the right white space.
106
69
107
70
There are two ways to add content to the margin: via the `{margin}` directive, and via adding CSS classes to your own content.
108
71
109
-
####Use a `{margin}` directive to add margin content
72
+
### Use a `{margin}` directive to add margin content
110
73
111
74
The `{margin}` directive allows you to create margin content with your own title and content block.
112
75
It is a wrapper around the Sphinx `{sidebar}` directive, and largely does its magic via CSS classes (see below).
113
76
114
77
Here's how you can use the `{margin}` directive:
115
78
79
+
````{example}
80
+
:no-container:
81
+
:reverse:
82
+
116
83
```{margin} **Here is my margin content**
117
84
It is pretty cool!
118
85
```
119
-
120
-
````
121
-
```{margin} **My margin title**
122
-
Here is my margin content, it is pretty cool!
123
-
```
124
86
````
125
87
126
-
####Use CSS classes to add margin content
88
+
### Use CSS classes to add margin content
127
89
128
90
You may also directly add CSS classes to elements on your page in order to make them behave like margin content.
129
91
To do so, add the `margin` CSS class to any element on the page.
130
92
Many Sphinx directives allow you to directly add classes.
131
93
For example, here's the syntax to add a `margin` class to a `{note}` directive:
132
94
133
-
:::{note}
134
-
:class: margin
135
-
This note will be in the margin!
136
-
:::
95
+
```{example}
96
+
:no-container:
97
+
:reverse:
137
98
138
-
```
139
99
:::{note}
140
100
:class: margin
141
101
This note will be in the margin!
142
102
:::
143
103
```
144
104
105
+
145
106
This works for most elements on the page, but in general this works best for "parent containers" that are the top-most element of a bundle of content.
146
107
147
108
For example, we can even put a whole figure in the margin like so:
@@ -151,16 +112,10 @@ You can also put the whole figure in the margin if you like.
151
112
Here is a figure with a caption below. We'll add a note below to create
152
113
some vertical space to see better.
153
114
154
-
```{figure} images/cool.jpg
155
-
---
156
-
figclass: margin
157
-
alt: My figure text
158
-
name: myfig4
159
-
---
160
-
And here is my figure caption
161
-
```
115
+
````{example}
116
+
:no-container:
117
+
:reverse:
162
118
163
-
````
164
119
```{figure} images/cool.jpg
165
120
---
166
121
figclass: margin
@@ -174,118 +129,94 @@ And here is my figure caption
174
129
We can reference the figure with {ref}`myfig4`. Or a numbered reference like
175
130
{numref}`myfig4`.
176
131
177
-
####Figure captions in the margin
132
+
### Figure captions in the margin
178
133
179
134
You can configure figures to use the margin for captions.
180
135
Here is a figure with a caption to the right.
181
136
182
-
```{figure} images/cool.jpg
183
-
---
184
-
width: 60%
185
-
figclass: margin-caption
186
-
alt: My figure text
187
-
name: myfig5
188
-
---
189
-
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 :-).
190
-
```
137
+
````{example}
138
+
:no-container:
139
+
:reverse:
191
140
192
-
And the text that produced it:
193
-
194
-
````
195
141
```{figure} images/cool.jpg
196
142
---
197
143
width: 60%
198
144
figclass: margin-caption
199
145
alt: My figure text
200
146
name: myfig5
201
147
---
202
-
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 :-)
148
+
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 :-).
203
149
```
204
150
````
205
151
206
152
We can reference the figure with {ref}`this reference <myfig5>`. Or a numbered reference like
207
153
{numref}`myfig5`.
208
154
209
-
### Content sidebars
155
+
### Examples of margin content
210
156
211
-
Content sidebars exist in-line with your text, but allow the rest of the
212
-
page to flow around them, rather than moving to the right margin.
213
-
To add content sidebars, use this syntax:
157
+
There are many kinds of content you can put in the margin, here are some examples.
214
158
215
-
````{sidebar} **My sidebar title**
216
-
```{note}
217
-
Here is my sidebar content, it is pretty cool!
218
-
```
219
-

220
-
````
221
-
222
-
Note how the content wraps around the sidebar to the right.
223
-
However, the sidebar text will still be in line with your content. There are
224
-
certain kinds of elements, such as "note" blocks and code cells, that may
225
-
clash with your sidebar. If this happens, try using a `{margin}` instead.
226
-
227
-
````
228
-
```{sidebar} **My sidebar title**
229
-
Here is my sidebar content, it is pretty cool!
230
-
```
231
-
````
232
-
233
-
### Adding content to margins and sidebars
234
-
235
-
Sidebar/margin content can include all kinds of things, such as code blocks:
236
-
237
-
````{margin} Code blocks in margins
238
-
```python
239
-
print("here is some python")
240
-
```
241
-
````
159
+
`````{example} Code blocks in the margin
160
+
:no-container:
161
+
:reverse:
242
162
243
-
`````
244
163
````{margin} Code blocks in margins
245
164
```python
246
165
print("here is some python")
247
166
```
248
167
````
249
168
`````
250
169
251
-
as well as admonitions and images:
170
+
`````{example} Admonitions and images in the margin
171
+
:no-container:
172
+
:reverse:
252
173
253
174
````{margin} **Notes in margins**
254
175
```{note}
255
176
Wow, a note with an image in a margin!
256
177

257
178
```
258
179
````
259
-
260
180
`````
261
-
````{margin} **Notes in margins**
181
+
182
+
## Sidebars
183
+
184
+
Sidebars exist in-line with your text, but allow the rest of the
185
+
page to flow around them, rather than moving to the right margin.
186
+
187
+
To add content sidebars, use this syntax:
188
+
189
+
`````{example}
190
+
:no-container:
191
+
192
+
````{sidebar} **My sidebar title**
262
193
```{note}
263
-
Wow, a note with an image in a margin!
264
-

194
+
Here is my sidebar content, it is pretty cool!
265
195
```
196
+

266
197
````
267
198
`````
268
199
200
+
Note how the content wraps around the sidebar to the right.
201
+
However, the sidebar text will still be in line with your content. There are
202
+
certain kinds of elements, such as "note" blocks and code cells, that may
203
+
clash with your sidebar. If this happens, try using a `{margin}` instead.
204
+
269
205
## Full-width content
270
206
271
207
Full-width content extends into the right margin, making it stand out against
272
208
the rest of your book's content. To add full-width content to your page, add the
273
209
class `full-width` to any of the elements in your documentation. For example, you can
274
210
add a `full-width` tag to a note element like this:
275
211
276
-
````
277
-
```{note}
278
-
:class: full-width
279
-
This content will be full-width
280
-
```
281
-
````
282
-
283
-
This code results in the following output:
212
+
````{example}
213
+
:no-container:
284
214
285
215
```{note}
286
216
:class: full-width
287
217
This content will be full-width
288
218
```
219
+
````
289
220
290
221
```{admonition} A note for ipynb users
291
222
If you are using a Jupyter Notebook as inputs to your documentation using the
0 commit comments