JunoLab / Weave.jl

Scientific reports/literate programming for Julia
http://weavejl.mpastell.com
MIT License
823 stars 94 forks source link

[BUG] Math not rendered when Plotly chosen as sPlots backend #405

Open baggepinnen opened 3 years ago

baggepinnen commented 3 years ago

description

I have a document that includes both plots and latex math. If I use GR as the backend by calling gr() in the beginning of the document, all math equations are rendered as expected. If I set plotly() as the backend, the math just renders verbatim as regular text.

versions

julia> versioninfo()
Julia Version 1.6.0-DEV.1437
Commit 68c71f5772 (2020-11-06 06:32 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.0 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 4
  JULIA_EDITOR = "/usr/share/code/code"
  JULIA_PKG_PRECOMPILE_AUTO = 1

using Pkg; Pkg.status():

(@v1.6) pkg> st Weave
Status `~/.julia/environments/v1.6/Project.toml`
[44d3d7a6] Weave v0.10.6 `~/.julia/dev/Weave` # up to date master branch

minimum reproducible steps

---
title : Vibration Damping
author : Fredrik Bagge Carlson
date: `j import Dates; Dates.Date(Dates.now())`
weave_options:
  term: false
  out_width: "50%"
  fig_width: 6
  wrap: true
  error: = false
  latex_cmd: [lualatex]
  mod: Main
---

```julia; echo = false
using Plots
plotly(show=false);

Introduction

Double-Mass Model

Let $θ$ denote the position of the motor mass and $q$ that of the arm mass, and let their inertias be $J_m, J_a$ respectively. The spring konstant $k$ couples the two masses and the three dampers with viscous damping coefficients $c_0, c_1, c_2$ model friction on the motor side, between the two masses and on the arm side.

This simple, linear model can be written in matrix form as $$ \begin{bmatrix}\dot\theta \ \ddot \theta \ \dot q \ \ddot q \end{bmatrix} = \begin{bmatrix} 0 & 1 & 0 & 0\ -k/J_m &-(c_0+c_1)/J_m & k/J_m & c_1/J_m\ 0 & 0 & 0 & 1\ k/J_a & c_1/J_a & -k/J_a & -(c_1+c_2)/J_a \end{bmatrix}\begin{bmatrix}\theta \ \dot \theta \ q \ \dot q \end{bmatrix} + \begin{bmatrix}0\k_τ\0\0\end{bmatrix}τ $$

square(t; f=1, ϕ=0) = sign(sin(2pi*f*t + ϕ))
t = 0:0.01:4
s1, s2 = square.(t), square.(t, ϕ=0.1)
sticks(t, [s1 s2 s1-s2], layout=(3,1), legend=false)