您好,我不太确定这个问题的best practice是什么,但也许可以考虑unicode-math
提供的range
选项.
如下图所示,由于我找不到这个代码了,暂无法提供文本形式的代码...
您好,我不太确定这个问题的best practice是什么,但也许可以考虑unicode-math
提供的range
选项.
如下图所示,由于我找不到这个代码了,暂无法提供文本形式的代码...
你好,请提供最小工作示例的文本
你上面的代码并不能直接复制就可以编译得到效果。
另一方面,我进行类似测试是完全可以实现你的需求的,你需要提供最小的一份可以复现你的问题的代码。
可以考虑使用\scriptscriptstyle
减小字号或者使用\!
插入负间距,如下mwe:
\documentclass{article}
\usepackage{lipsum}
\usepackage{amsmath}
\begin{document}
\[ g_{ijk} (\mathbf{R}_j,\mathbf{R}) \]
\[ g_{IJK} (\mathbf{R}_j,\mathbf{R}) \]
\[ g_{\scriptscriptstyle {IJK}} (\mathbf{R}_j,\mathbf{R}) \]
\[ g_{\text{IJK}} (\mathbf{R}_j,\mathbf{R}) \]
\[ g_{I,J,K} (\mathbf{R}_j,\mathbf{R}) \]
\[ g_{\scriptscriptstyle {I,J,K}} (\mathbf{R}_j,\mathbf{R}) \]
\[ g_{I\!J\!K} (\mathbf{R}_j,\mathbf{R}) \]
\[ g_{I\!\!J\!\!K} (\mathbf{R}_j,\mathbf{R}) \]
\end{document}
我比较笨...
也不擅长TiKZ...
只能给出一条线一条线慢慢画的回答
..下面的代码其实还有很对可以改进的地方,比如一些代码复用,部分定位仍需要手动调整,部分连接处似乎是因为浮点误差有些小瑕疵等,部分位置的微调你自己看texdoc tikz
文档调整吧
我不喜欢TiKZ!
\documentclass[margin=1.5cm]{standalone}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{positioning,calc,intersections}
\begin{document}
\begin{tikzpicture}[
every node/.style = {circle,outer sep=0pt,inner sep=.1pt},
lineleft/.style = {color = red!80,dashed,line cap=round},
lineright/.style = {color = green!70!black,line cap=round},
]
\node (node-22) {$a_{22}$};
\node (node-21) [left = of node-22] {$a_{21}$};
\node (node-23) [right = of node-22] {$a_{23}$};
\node (node-12) [above = of node-22] {$a_{12}$};
\node (node-11) [left = of node-12] {$a_{11}$};
\node (node-13) [right = of node-12] {$a_{13}$};
\node (node-32) [below = of node-22] {$a_{32}$};
\node (node-31) [left = of node-32] {$a_{31}$};
\node (node-33) [right = of node-32] {$a_{33}$};
\node (extra-north) [above = of node-12] {\phantom{$a_{12}$}};
\node (extra-east) [right = of node-23] {\phantom{$a_{23}$}};
\node (extra-west) [left = of node-21] {\phantom{$a_{21}$}};
\node (extra-south) [below = of node-32] {\phantom{$a_{32}$}};
\node (extra-southeast) [right = of node-33] {\phantom{$a_{31}$}};
\node (extra-southwest) [left = of node-31] {\phantom{$a_{31}$}};
\node (M1) at ($(node-11)!.5!(extra-west)$) {};
\node (M2) at ($(node-11)!.5!(extra-north)$) {};
\node (N1) at ($(node-13)!.5!(extra-east)$) {};
\node (N2) at ($(node-13)!.5!(extra-north)$) {};
\draw[lineright]
(extra-north.center) -- (node-13) -- (extra-east.center)
(M2.center) -- (node-12) -- (node-23) -- (extra-southeast)
(node-11) -- (node-22) -- (node-33)
(M1.center) -- (node-21) -- (node-32)
(extra-west.center) -- (node-31) -- (extra-south.center)
;
\draw[lineleft]
(extra-west.center) -- (node-11) -- (extra-north.center)
(N2.center) -- (node-12) -- (node-21) -- (extra-southwest)
(node-31) -- (node-22) -- (node-13)
(N1.center) -- (node-23) -- (node-32)
(extra-south.center) -- (node-33) -- (extra-east.center)
;
\draw[lineright,name path=circ1] let \p1 = ($(M2.center) - (extra-west.center)$),
\n{radius} = {veclen(\x1,\y1)/2}
in
(M2.center) arc (45:225:\n{radius});
\draw[lineright,name path=circ2] let \p1 = ($(M1.center) - (extra-north.center)$),
\n{radius} = {veclen(\x1,\y1)/2}
in
(extra-north.center) arc (45:225:\n{radius});
\draw[lineleft,name path=circ3] let \p1 = ($(N2.center) - (extra-east.center)$),
\n{radius} = {veclen(\x1,\y1)/2}
in
(N2.center) arc (135:-45:\n{radius});
\draw[lineleft,name path=circ4] let \p1 = ($(N1.center) - (extra-north.center)$),
\n{radius} = {veclen(\x1,\y1)/2}
in
(extra-north.center) arc (135:-45:\n{radius});
\draw[lineright,line cap=round,name intersections={of=circ1 and circ2}] (intersection-1)-- (node-11);
\draw[lineleft,line cap=round,name intersections={of=circ3 and circ4}] (intersection-1)-- (node-13);
\node[rectangle] (text1) [below left=.8cm of extra-west,xshift=1.05cm] {\textcolor{red!80}{$-a_{1,1}a_{2,3}a_{3,2}$}};
\draw[lineleft] (text1.north) -- (extra-west.center);
\node[rectangle,xshift=.1cm] (text2) at (extra-southwest) {\textcolor{red!80}{{$-a_{1,2}a_{2,1}a_{3,3}$}}};
%\draw[lineleft] (text2.north) -- (node-21);
\node[rectangle] (text3) [below left=.5cm of node-31,xshift=1cm] {\textcolor{red!80}{$-a_{1,3}a_{2,3}a_{3,1}$}};
\draw[lineleft] (text3.north) -- (node-31);
\node[rectangle] (text4) [below right=.8cm of extra-east,xshift=-1cm] {\textcolor{green!70!black}{$+a_{1,3}a_{2,1}a_{3,2}$}};
\draw[lineright] (text4.north) -- (extra-east.center);
\node[rectangle,xshift=.1cm] (text5) at (extra-southeast) {\textcolor{green!70!black}{$+a_{1,2}a_{2,3}a_{3,1}$}};
% %\draw[lineright] (text5.north) -- (node-23);
\node[rectangle] (text6) [below right=.5cm of node-33,xshift=-1cm] {\textcolor{green!70!black}{$+a_{1,1}a_{2,2}a_{3,3}$}};
\draw[lineright] (text6.north) -- (node-33);
\end{tikzpicture}
\end{document}
效果如下:
提供mwe还是要完整...
tocbibind
宏包会将由thebibliography
生成的参考文献加入目录,但是你也不应该同时使用\section*{参考文献}
新增一个section
,这样会在参考文献处出现两行“参考文献”。
所以,你还是需要提供完整的mwe才好防止可能出现的其他问题...
虽然MWE还是不太规范,但至少你学会了围栏代码块语法...
似乎找到了你模仿的原文档代码,分析你的报错信息,提示Error: Bad column type
,说明是S
列格式 不能被识别,文档中写的很清楚,需要加载siunitx
宏包...
另外 [code-before = ... ]
似乎是已经过时的接口,请关注最新版的nicematrix
文档
下面才是正常的MWE(需要包含\documentclass
到\end{docuement}
的全部内容啊不然怎么直接复制就能编译...)
\documentclass[12pt]{ctexart}
\usepackage{hyperref}
\usepackage{nicematrix}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\section{NiceMatrix}
\begin{NiceTabular}[c]{lSSSS}
\CodeBefore
\rowcolor{red!15}{1-2}
\rowcolors{3}{blue!15}{}
\Body
\toprule
\Block{2-1}{Product} &
\Block{1-3}{dimensions (cm)} & & &
\Block{2-1}{\rotate Price} \\
\cmidrule(rl){2-4}
& L & l & h \\
\midrule
small & 3 & 5.5 & 1 & 30 \\
standard & 5.5 & 8 & 1.5 & 50.5 \\
premium & 8.5 & 10.5 & 2 & 80 \\
extra & 8.5 & 10 & 1.5 & 85.5 \\
special & 12 & 12 & 0.5 & 70 \\
\bottomrule
\end{NiceTabular}
\end{document}
请将代码放置到围栏代码块语法中,以保证正确的高亮
建议使用【补充问题】功能,并在编辑完毕后善用【预览】功能
同时建议提供完整的mwe
摸鱼的时候测试了一下,下面是一个MWE:
\documentclass[12pt]{ctexart}
\usepackage{amsmath}
\usepackage{cases}
\usepackage{empheq}
\setlength{\parindent}{0pt}
\begin{document}
原始的表达(cases或者\verb|\left\{\right.|方法)均难以在cases内部编号:
\begin{equation}
\left\{
\begin{aligned}
B&=B_{\text{地}}+B_{++}+B_{s}+B_{sl} \\
B&=B_{\text{地}}+B_{++}^{prime}+B_{s}-B_{sl}
\end{aligned}
\right.
\end{equation}
\begin{equation}
\begin{cases}
B = B_{\text{地}} + B_{++} + B_{s} + B_{sl}\\
B = B_{\text{地}} + B_{++}^{prime} + B_{s} - B_{sl}
\end{cases}
\end{equation}
solution1:\verb|cases|环境中分行添加序号可以使用\verb|cases|宏包提供的\verb|numcases|环境实现(注意该宏包须在\verb|amsmath|之后调用).
\begin{numcases}{}
B=B_{\text{地}}+B_{++}+B_{s}+B_{sl} \\
B=B_{\text{地}}+B_{++}^{prime}+B_{s}-B_{sl}
\end{numcases}
solution2:使用\verb|empheq|宏包提供的环境来实现大括号内的多行编号
\begin{empheq}[left=\empheqlbrace]{align}
B &= B_{\text{地}} + B_{++} + B_{s} + B_{sl}\\
B &= B_{\text{地}} + B_{++}^{prime} + B_{s} - B_{sl}
\end{empheq}
\end{document}
怀疑是calculations
环境的bug
可以将下图所示的 值从默认的0.3修改为更大的值(例如0.48),这是出现当columns=2
时整体向左偏移的原因
之后代码编译宽度正常
本弹性强迫症也来给一个briefly summary:
参考自tse上的另一个回答,大致有以下三种方案:
amsthm
宏包ntheorem
宏包thmtools
宏包方案一:
\documentclass{ctexart}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{lipsum,zhlipsum}
\newtheoremstyle{no-bracket}
{\topsep}
{\topsep}
{\normalfont\itshape}
{0pt}
{\bfseries}
{} %{:}
{\newline}
%{\thmname{#1}~\thmnumber{#2}\thmnote{ \textlangle#3\textrangle}}
{\thmname{#1}~\thmnumber{#2}\thmnote{ #3: }}
\theoremstyle{no-bracket}
\newtheorem{theorem}{定理}[section]
\begin{document}
\noindent 使用\verb|amsthm|宏包的\verb|\newtheoremstyle|修改参数\verb|<CUSTOM-HEAD-SPEC>|实现
\section{这是一个章节}
\begin{theorem}[Fundamental Theorem of Algebra]
\lipsum[2]
\end{theorem}
\begin{theorem}[代数学基本定理]
Fundamental Theorem of Algebra
\end{theorem}
\begin{theorem}[代数学基本定理]
\zhlipsum[1]
\end{theorem}
\end{document}
方案二:
\documentclass[12pt]{ctexart}
\usepackage{amsmath}
\usepackage{lipsum,zhlipsum}
\usepackage{ntheorem}
\makeatletter
\newtheoremstyle{no-bracket}
{
\item[
\rlap{\vbox{\hbox{\hskip\labelsep
\theorem@headerfont ##1\ ##2\theorem@separator}
\hbox{\strut}}}
]
}%
{
\item[
\rlap{\vbox{\hbox{\hskip\labelsep
\theorem@headerfont ##1\ ##2\ ##3: \theorem@separator}\hbox{\strut}}}
%冒号加在这里不会有空格
]
}
\makeatother
\theoremstyle{no-bracket}
%\theoremseparator{:} %出现空格
\newtheorem{theorem}{Theorem}
\begin{document}
\noindent 使用\verb|ntheorem|宏包的\verb|\newtheoremstyle|命令
\section{这是一个章节}
\begin{theorem}[Fundamental Theorem of Algebra]
\lipsum[2]
\end{theorem}
\begin{theorem}[代数学基本定理]
Fundamental Theorem of Algebra
\end{theorem}
\begin{theorem}[代数学基本定理]
\zhlipsum[1]
\end{theorem}
\end{document}
方案三:
\documentclass[10pt,a4paper]{ctexart}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{lipsum,zhlipsum}
\usepackage{thmtools} %
\declaretheoremstyle[
spaceabove=\topsep,
spacebelow=\topsep,
headfont=\normalfont\bfseries,
notefont=\bfseries,
notebraces={}{},
bodyfont=\normalfont\itshape,
postheadspace=\newline,
headpunct={:},
]{no-bracket}
\declaretheorem[style=no-bracket,name=Theorem]{theorem}
\begin{document}
\noindent 使用\verb|thmtools|宏包的\verb|\declaretheoremstyle|命令设置
\section{这是一个章节}
\begin{theorem}[Fundamental Theorem of Algebra]
\lipsum[2]
\end{theorem}
\begin{theorem}[代数学基本定理]
Fundamental Theorem of Algebra
\end{theorem}
\begin{theorem}[代数学基本定理]
\zhlipsum[1]
\end{theorem}
\end{document}
我来自己提供一个tabularray
的方法....
%\usepackage{xcolor}
%\usepackage{tabularray}
\begin{tblr}{
hlines,
vlines,
colspec = {cQ[c,cyan7]Q[c,azure7]Q[c,blue7]},
row{1} = {bg=cyan},
hline{3} = {2-4}{red},
hline{5} = {2-4}{cyan},
hline{7} = {2-4}{violet},
cell{2}{1} = {r=2,c=1}{c,orange!60},
cell{4}{1} = {r=2,c=1}{c,orange!60},
cell{6}{1} = {r=2,c=1}{c,orange!60},
}
$\beta$ & $50$ & $100$ & $150$ \\
静态工作点& AAA & BBB & CCC \\
& DDD & EEE & FFF \\
动态工作点& AAA & BBB & CCC \\
& DDD & EEE & FFF \\
等离子态工作点& AAA & BBB & CCC \\
& DDD & EEE & FFF \\
\end{tblr}
尝试看了下模板源代码,结果头昏目眩了...
记录下探索发现
P.S.如果问题涉及多个需求建议分点阐述
有如下的发现:
关于问题4: 最软的柿子是 "注"...只是因为你在"注"字前多打了一个空格
关于问题3: MWE中采用的是enumerate
环境,在普通的文档类中要想简单地取消其缩进可以考虑 https://tex.stackexchange.com/questions/241983/remove-indent-when-using-enumerate 中的做法(虽然这样会去掉enumerate自动缩进的层次感并不推荐)
然而exam-zh
环境对\solution
环境进行了高度的自定义,这种做法并不能生效....代码逻辑有点看不动了...坐等肉丝老师(搓手手)
关于问题2:请查看exam-zh-doc
中关于index
选项的说明
关于问题1:我觉得也是不太好处理的...要适配不同长度的index
得改不少地方
对于不同宽度的序号的默认显示效果如下:
在exam-zh
中question/label-align
以及problem/label-align
的默认对齐方式均为right
,在exam-zh-question.sty
中:
\str_case:Vn \l__examzh_problem_label_align_tl
控制了problem
不同情况下item的缩进方式\str_case:Vn \l__examzh_question_label_align_tl
控制了question
下item的缩进方式\str_case:Vn \l__examzh_question_label_align_tl
以及\str_case:Vn \l__examzh_problem_label_align_tl
通过不同的弹性长度来调整标号的水平位置。....嗯...但我没改出来呜呜
在exam-zh-symbols.sty
中提供了\__examzh_symbols_frac_calc_str_num:nn
用于获取数位,结合不同分类情况也许可以实现...
听说 鱼香肉丝先生正是 exam-zh
的 maintainer,那就交给他好了.
还有一个小问题,如果需要输入(12分)
,请使用选项[points=12]
而不是直接输入。
公元2024年9月19号下午,华夏某LaTeX交流群出现了因建模比赛将近而GMCMthesis模板在overleaf上编译出现字体LiSu字体缺失的问题,引起激烈的讨论,下面就此问题进行记录(下面的问题将集中在隶书字体)。
首先介绍本地环境中在powershell
终端使用fc-list
命令可以获取本机当前为所有用户安装的字体列表,如下图所示(如果终端的字符编码不是utf-8
还可能需要通过借助chcp 65001
命令切换终端编码样式或者修改终端的字体来保证中文正常显示,我的设备还是会中文乱码,因此我也很苦恼...)
由于个人比较喜欢折腾,这里也贴出常见的几种fc-list
命令的附加命令(特别感谢Osbert Wang)感兴趣的朋友可以试试他们的使用效果。
# 以完整格式输出中文字体并在终端输出
fc-list :lang=zh-cn
# 以完整格式输出英文字体并保存在当前路径下的enfonts.txt文件中
fc-list :lang=en > enfonts.txt
# 只输出字族,达到使用\setmainfont的使用需求
fc-list :lang=zh-cn family
# 使用--format选项格式化输出fc-list的结果
fc-list :lang=zh --format="%{family[0]}\n" | sort
fc-list :lang=zh --format="%{family[0]},%{family[1]}\n"
# 使用功能更强的终端如powershell可以实现去重/排序等功能
fc-list :lang=zh --format="%{family[0]},%{family[1]}\n" | Sort-Object | Get-Unique | Out-File zhfont.txt -Encoding default
在这里还必须提到,对于已经安装的字体,TeX引擎会通过其字体族(font family)的名称来调用;而对于只提供字体文件(.otf
,.ttf
)的字体,TeX会优先搜索当前工作路径下的字体文件并进行调用,这样的好处是避免操作系统安装的字体过多过于复杂(具体的例子可见下图,特别感谢Eureka大神提供的开源仓库 All about TeX 走过路过可以点一个star)。
P.S. 我本人对字体的使用问题完全可以说是七窍通了六窍,在LaTeX(尤其是模板)的使用中字体的配置问题由于各种系统的差异以及版权问题往往是令人头疼的,此处仅提供在不同平台下编译效果的实际测试与经验汇总。
作为后文介绍的前置知识,我们还应该知道GMCMthesis
实际上调用的文档类是ctex
宏包提供的ctexart
文档类,其文档中对不同系统的字体调用情况说明如下图:
-------前面都是一些为了内容完整性的(废话)------这是一条分割线-----
本文将从使用四种测试环境,测试的代码使用从GMCMthesis-github拉取的example.tex
文件为准。
本地编译环境(windows11+TeXLive2024)
LiSu
字体的情况(比如一台刚刚装过windows11系统的干干净净的电脑)下,LiSu
这一字体是一点点小问题的(见下图,但是警告不是错误,可以忽略),但不影响使用xelatex
编译example.tex
顺利通过。LiSu
字体,也即使用fc-list :lang=zh | findstr "LiSu"
可以检索到隶书字体C:/Windows/fonts/SIMLI.TTF: LiSu,隶书:style=Regular
时,使用xelatex
编译example.tex
模板是完美编译的。xelatex
编译example.tex
文件的效果同windows11+TeXLive2024Fandol
字库)example.tex
文档首先说明如果需要在OverLeaf
上编译,则需要选择相应的字库选项如下:
% \documentclass[bwprint]{gmcmthesis}
\documentclass[bwprint,fontset=fandol]{gmcmthesis} % OverLeaf 等在线平台需要用这一行。
在如上图上传项目文档后,使用xelatex
编译example.tex
文件
首先需要指出的是,警告并不影响最终编译结果,在宏包heavenlyclouds
的作用下,由于ubuntu
系统不自带隶书,因此其策略自动选择用楷书代替并raise这个warning。
与此同时,比赛官方仅仅提供了一个word模板,并未有严格的格式规范,所以实际上并不一定非要使用隶书,建模比赛更重要的还是内容,分辨字体是否正确不是一个评审应该重点关注的事情,和本科生国赛一样,其实并没有格式要求,只需要排版整洁美观严谨就是一个好的文档样式。
既然鱼香肉丝老师发问了,这里记录下群里讨论出的解决方法:
感谢群友@u19850 可以在example.tex
同层文件目录下上传LiSu.ttf
文件,并且将.cls
中的代码修改如下:
% 将gmcmthesis.cls的 316行左右 处修改如下,处理字体兼容
\ifmcm@fandol
% \setCJKfamilyfont{zhli}{LiSu} % 需要隶书字体 最好更换其他相似字体
\setCJKfamilyfont{zhli}{LiSu.ttf}
\newcommand*\lishu{\CJKfamily{zhli}}
% \providecommand{\lishu}{\kaishu}
% \PackageWarning{heavenlyclouds}{用楷书代替隶书}
\fi
如此做,便可通过当前目录下字体.ttf
文件的直接调用解决找不到字体的问题。
由于一些版权的原因,此处无法提供LiSu.ttf
文件,请自行下载并上传到工作路径下。
TeXpage
实际上TeXpage的编译表现和Overleaf完全相同
在上传LiSu.ttf
并进行字体兼容后,在TeXpage使用xelatex
在TeXLive2024
下也可正常编译.
这个问题问得非常好,也是LaTeX交流群中最常见的(入门必读)的一个问题!
感谢肉丝老师的馈赠~
LaTeX
最快的入门手册是lshort-zh-cn
文档(强烈建议花至少111分钟熟悉该文档并亲自尝试(just get your hands dirty!))4LaTeX
有疑问的,请阅读OsbertWang精心编写(他真的我哭死,甚至在2024年9月又更新了一版)的install-latex-guide-zh-cn
文档,所有的TeXLive
安装问题都能在这里找到答案。反引号的输入可见下图(在英文状态下输入):
Happy TeXing!
OsbertWang指出,并不是所有字体的宏包均包含了对应的字体,有部分仅仅是提供了调用字体的接口。
因此 https://ask.latexstudio.net/ask/question/3298.html 中的做法是合理的。
另一方面,mathdesign
宏包的文档还提到容易发生宏包冲突
做一个简单的总结,2024年9月测试,windows系统下如果要调用garamond
数学字体,大致有以下三种可行的方案
unicode-math
提供的\setmainfont
调用\usepackage{unicode-math}
\setmathfont{Garamond-Math}
newtxmath
宏包提供的garamond选项\usepackage[ebgaramond]{newtxmath}
Garamond-Math
宏包文档提供的方法\usepackage[math-style=ISO, bold-style=ISO]{unicode-math}
\setmainfont{EB Garamond}%You should have installed the font
\setmathfont{Garamond-Math.otf}[StylisticSet={7,9}]
问 如何将LaTeX的公式字体中数学符号替换为别的宏包的符号?