尝试设置节/子节的样式时出错

尝试设置节/子节的样式时出错

我已遵循此示例进行部分样式设置。

如何在 LaTeX 中创建具有“<title> <number>”格式的自定义章节标题?

MWE 中没有错误,但是当我将其插入论文时,每次出现章节或小节时都会出现此错误。我拥有所有必需的库。

我已将代码修改如下。

在此处输入图片描述

        %Title 
    \titleformat{\section}[hang]{\sffamily\color{DarkGrey}\bfseries\scshape\fillright\lsstyle}{}{0.5em}{{\Huge\thesection}\quad\rule[-0.25cm]{1.5pt}{1cm}\quad\Huge#1}%
    
    % Subtitle
    \titleformat{\subsection}[hang]{\sffamily\color{DarkGrey}\bfseries\scshape\fillright\lsstyle}{}{0.5em}{{\Large\thesubsection}\hspace{0.15cm}\rule[-0.15cm]{1.5pt}{0.7cm}\hspace{0.15cm}\Large#1}%
    
    Original line of code from exemple 
    \titleformat{\section}[hang]{\sffamily\color{IndianRed3}\bfseries\scshape\filleft\lsstyle}{}{2em}{#1\quad\rule[-0.25cm]{1.5pt}{1cm}\rlap{\qquad\Huge \thesection}}%

问题发生在哪里

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx,eso-pic,lipsum,etoolbox}
\usepackage[explicit]{titlesec}
\usepackage{microtype}
\usepackage{letterspace}
\definecolor{DarkGrey}{RGB}{60, 60, 60}

%First title
%https://tex.stackexchange.com/questions/193446/how-to-create-custom-section-titles-with-a-title-number-format-in-latex
\titleformat{\section}[hang]{\sffamily\color{DarkGrey}\bfseries\scshape\fillright\lsstyle}{}{0.5em}{{\huge\thesection}\quad\rule[-0.25cm]{1.5pt}{1cm}\quad\Huge#1}%

% Subtitle
\titleformat{\subsection}[hang]{\sffamily\color{DarkGrey}\bfseries\scshape\fillright\lsstyle}{}{0.5em}{{\Large\thesubsection}\hspace{0.15cm}\rule[-0.15cm]{1.5pt}{0.7cm}\hspace{0.15cm}\Large#1}%

    
\begin{document}

\section{Introduction} \label{intr}

\lipsum[1-2]

\end{document}

这是 MWE 错误的原始日志

    <argument> ...kGrey}\bfseries \scshape \fillright 
                                                  \lsstyle 
l.22 \section{Introduction}
                            \label{intr}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

LaTeX Font Info:    Trying to load font information for OT1+lmr on input line 22.
(/usr/local/texlive/2021/texmf-dist/tex/latex/lm/ot1lmr.fd
File: ot1lmr.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
)
LaTeX Font Info:    Trying to load font information for OML+lmm on input line 22.
(/usr/local/texlive/2021/texmf-dist/tex/latex/lm/omllmm.fd
File: omllmm.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
)
LaTeX Font Info:    Trying to load font information for OMS+lmsy on input line 22.
(/usr/local/texlive/2021/texmf-dist/tex/latex/lm/omslmsy.fd
File: omslmsy.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
)
LaTeX Font Info:    Trying to load font information for OMX+lmex on input line 22.
(/usr/local/texlive/2021/texmf-dist/tex/latex/lm/omxlmex.fd
File: omxlmex.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
)
LaTeX Font Info:    External font `lmex10' loaded for size
(Font)              <12> on input line 22.
LaTeX Font Info:    External font `lmex10' loaded for size
(Font)              <8> on input line 22.
LaTeX Font Info:    External font `lmex10' loaded for size
(Font)              <6> on input line 22.
[1  

相关内容