如何解决Julia 情节标题中的常规文本和 LaTeX 的混合
尝试了所有方法,除了在我的情节中获得以下标题的方法:"Volume in m^3 at threshold=30"
。阈值应该来自一个名为 threshold
的变量。
using Plots
using LaTeXStrings
threshold = 30
plot(1:10)
title!("Volume in \$m^3\$ at threshold=$threshold")
# The following works with a hard-coded value for threshold
title!(@L_str("\\textrm{Volume in }m^3\\textrm{ at threshold=30}"))
# The following fails:
s = "\\textrm{Volume in }m^3\\textrm{ for threshold=$threshold}"
title!(@L_str(s))
Error message:
ERROR: LoadError: MethodError: no method matching
@L_str(::LineNumberNode,::Module,::Symbol)
Closest candidates are:
@L_str(::LineNumberNode,::String) at
/home/tarik/.julia/packages/LaTeXStrings/YQ4GM/src/LaTeXStrings.jl:68
in expression starting at REPL[25]:1
解决方法
好的,通过避免 L
宏找到了一个解决方案,该宏除了在字符串的开头和结尾添加 $
符号外似乎没有什么作用。
using Plots
using LaTeXStrings
threshold = 30
s="\$\\textrm{Volume in }m^3\\textrm{ at threshold=$threshold}\$"
plot(1:30)
title!(s)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。