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
@@ -186,24 +189,26 @@ The default starting number is `1`, but if you need to start at a different valu
186
189
187
190
To change the left or right offset of the equation number, use the `equationNumberOffset` modifier.
188
191
189
-
```swift
190
-
// Don't number block equations (default)
191
-
LaTeX("$$a + b = c$$")
192
-
.equationNumberMode(.none)
192
+
##### Format Equation Number
193
+
194
+
You can set a closure on the view to do your own custom formatting. The `formatEquationNumber` modifier takes a closure that is passed the equation number and returns a string.
193
195
194
-
// Add left numbers and a leading offset
195
-
LaTeX("$$d + e = f$$")
196
-
.equationNumberMode(.left)
196
+
```swift
197
+
LaTeX("$$E = mc^2$$")
198
+
.equationNumberMode(.right)
197
199
.equationNumberOffset(10)
200
+
.padding([.bottom])
198
201
199
-
// Add right numbers, a leading offset, and start at 2
The view has four rendering styles. The `wait` style is the default style, and loads the view synchronously on the main queue. To get better performance and move SVG rendering off of the main queue, use any of the other three styles.
|`empty`| Yes | The view remains empty until its finished rendering. |
235
+
|`original`| Yes | The view displays the input text until its finished rendering. |
236
+
|`progress`| Yes | The view displays a progress view until its finished rendering. |
237
+
|`wait`| No |*(default)* The view blocks the main queue until its finished rendering. |
238
+
239
+
240
+
#### 🪩 Animated
241
+
242
+
The `animated` modifier applies to the view when using the asynchronous rendering styles `empty`, `original`, or `progress`.
243
+
244
+
```swift
245
+
LaTeX(input)
246
+
.renderingStyle(.original)
247
+
.animated()
248
+
```
249
+
250
+
> In the above example, the input text will be displayed until the SVGs have been rendered at which point the rendered views will animate in to view.
251
+
223
252
### 🗄️ Caching
224
253
225
254
`LaTeXSwiftUI` caches its SVG responses from MathJax and the images rendered as a result of the view's environment. If you want to control the cache, then you can access the static `dataCache` and `imageCache` properties.
@@ -240,8 +269,6 @@ LaTeX.imageCache.removeAll()
240
269
241
270
SVGs and images are rendered and cached on demand, but there may be situations where you want to preload the data so that there is minimal lag when the view appears.
242
271
243
-
SVGs and images are rendered as a result of the view's environment, so it is important to call the `preload` method last in the view's modifier chain if you use it.
244
-
245
272
```swift
246
273
VStack {
247
274
ForEach(expressions, id: \.self) { expression in
@@ -255,3 +282,5 @@ VStack {
255
282
}
256
283
}
257
284
```
285
+
286
+
SVGs and images are rendered as a result of the view's environment, so it is important to call the `preload` method last in the view's modifier chain if you use it.
0 commit comments