我希望用数学模式写一封信,并在章节标题中以粗体显示。
运行这个
\documentclass[
pdftex,a4paper,11pt,oneside,fleqn,
bibliography=totoc,listof=totoc,
headlines=2.1,headsepline,
numbers=noenddot
]{scrreprt}
%%%----- PDF Format -----------------------------
\usepackage{float}
\usepackage[pdftex,pdfpagelabels,bookmarks,bookmarksopen,bookmarksnumbered,
bookmarksopenlevel = 1,
pdfstartpage = 1,
pdfstartview = FitV,
pdfpagelayout = SinglePage,
plainpages = false,
hypertexnames = false,
colorlinks = true,
linkcolor = black,
citecolor = black,
urlcolor = black
]{hyperref}
%%%----- Mathe ----------------------------------
\usepackage{amsmath,amsfonts,amssymb,bm}
\usepackage[squaren,textstyle]{SIunits}
\usepackage{icomma}
\usepackage{mathtools}
\usepackage[makeroom]{cancel}
\begin{document}
\section{Filtered-$\boldsymbol{x}$-LMS (FxLMS)-Algorithmus}
blabla
\begin{align*}
a \cdot b\\
c {\cdot} d
\end{align*}
\end{document}
我收到以下错误:
! Illegal parameter number in definition of \BKM@title.
答案1
您显示的代码不会产生错误。但如果我添加
\usepackage{hyperref}
\usepackage{bookmark}
我确实
! Illegal parameter number in definition of \BKM@title.
<to be read again>
2
l.14 ...-$\boldsymbol{x}$-LMS (FxLMS)-Algorithmus}
问题是,在\boldsymbol
书签制作过程中无法保存。标准的解决方法是
\section{Filtered-\texorpdfstring{$\boldsymbol{x}$}{x}-LMS (FxLMS)-Algorithmus}
完整代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb,bm}
\usepackage[squaren,textstyle]{SIunits}
\usepackage{icomma}
\usepackage{mathtools}
\usepackage[makeroom]{cancel}
\usepackage{hyperref}
\usepackage{bookmark}
\begin{document}
\section{Filtered-\texorpdfstring{$\boldsymbol{x}$}{x}-LMS (FxLMS)-Algorithmus}
blabla
\end{document}
几点说明。
由于有些年份,\usepackage[utf8]{inputenc}
可以省略。
该软件包SIunits
很旧,并且无人维护。您应该切换到siunitx
功能更强大、维护和开发更完善的软件包。
您可以使用\bm
代替\boldsymbol
:它更短。
答案2
由于您使用的是 Koma-Script 类(scrreprt
),您可以通过在序言中添加此行来使章节标题中的所有数学内容变为粗体:
\addtokomafont{sectioning}{\boldmath}
因此,修改后的 MWE:
\documentclass[
pdftex,a4paper,11pt,oneside,fleqn,
bibliography=totoc,listof=totoc,
headlines=2.1,headsepline,
numbers=noenddot
]{scrreprt}
%%%----- PDF Format -----------------------------
\usepackage{float}
\usepackage[pdftex,pdfpagelabels,bookmarks,bookmarksopen,bookmarksnumbered,
bookmarksopenlevel = 1,
pdfstartpage = 1,
pdfstartview = FitV,
pdfpagelayout = SinglePage,
plainpages = false,
hypertexnames = false,
colorlinks = true,
linkcolor = black,
citecolor = black,
urlcolor = black
]{hyperref}
%%%----- Mathe ----------------------------------
\usepackage{amsmath,amsfonts,amssymb,bm}
\usepackage[squaren,textstyle]{SIunits}
\usepackage{icomma}
\usepackage{mathtools}
\usepackage[makeroom]{cancel}
\addtokomafont{sectioning}{\boldmath}
\begin{document}
\section{Filtered-$x$-LMS (FxLMS)-Algorithmus}
blabla
\end{document}
这混合了衬线和无衬线字体,但您也可以更改字体sectioning
,或选择粗体无衬线数学样式用于标题。
\documentclass[
pdftex,a4paper,11pt,oneside,fleqn,
bibliography=totoc,listof=totoc,
headlines=2.1,headsepline,
numbers=noenddot
]{scrreprt}
%%%----- PDF Format -----------------------------
\usepackage{float}
\usepackage[pdftex,pdfpagelabels,bookmarks,bookmarksopen,bookmarksnumbered,
bookmarksopenlevel = 1,
pdfstartpage = 1,
pdfstartview = FitV,
pdfpagelayout = SinglePage,
plainpages = false,
hypertexnames = false,
colorlinks = true,
linkcolor = black,
citecolor = black,
urlcolor = black
]{hyperref}
%%%----- Mathe ----------------------------------
\usepackage{amsmath,amsfonts,amssymb,bm}
\usepackage[squaren,textstyle]{SIunits}
\usepackage{icomma}
\usepackage{mathtools}
\usepackage[makeroom]{cancel}
\DeclareMathVersion{boldsans}
\SetSymbolFont{operators}{boldsans}{OT1}{cmsmf} {bx}{n}
\SetSymbolFont{letters} {boldsans}{OML}{cmssm} {b}{it}
\SetSymbolFont{symbols} {boldsans}{OMS}{cmsssy}{b}{n}
\SetSymbolFont{largesymbols}{boldsans}{OMX}{cmssex}{m}{n}
\addtokomafont{sectioning}{\mathversion{boldsans}}
\begin{document}
\section{Filtered-$x$-LMS (FxLMS)-Algorithmus}
{\mathversion{boldsans}
\[ \int \frac{\sqrt{\epsilon}}{x} \mathop{\mathrm{d}x}{} = \sqrt{\epsilon} \ln x + C
\]
}
\end{document}