Latex 没有编号的章节标题有一种奇怪的行为

Latex 没有编号的章节标题有一种奇怪的行为,latex,r-markdown,knitr,Latex,R Markdown,Knitr,我正在使用Rmarkdown和Knitr用定制的乳胶模板写我的硕士学位回忆录。几乎每件事都很好,但有什么事困扰着我 未编号的节标题无法按预期工作 我在章节标题的末尾使用了{-}符号,就像文档中所说的那样 章节未在TOC中编号,但实际章节标题用星号编号,标题名称在后面一行(见摘要中的图片) 您可以在中看到结果 您可以通过以下方式克隆可恢复的R项目: git clone https://framagit.org/Roelandtn/reprex_bug_headers.git 我认为这个问题来自

我正在使用Rmarkdown和Knitr用定制的乳胶模板写我的硕士学位回忆录。几乎每件事都很好,但有什么事困扰着我

未编号的节标题无法按预期工作

我在章节标题的末尾使用了
{-}
符号,就像文档中所说的那样

章节未在TOC中编号,但实际章节标题用星号编号,标题名称在后面一行(见摘要中的图片)

您可以在中看到结果

您可以通过以下方式克隆可恢复的R项目:

git clone https://framagit.org/Roelandtn/reprex_bug_headers.git
我认为这个问题来自于我使用的自定义模板,但我不明白为什么或者如何纠正这个问题。有人能看看吗

如何复制:

  • 复制回购协议
  • 用Rstudio打开Rproject
  • 打开reprex_bug_headers.Rmd文件
  • 编辑pdf文档
提前感谢,

尼古拉斯

其他信息:

> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.4 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
 [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C               LC_TIME=fr_FR.UTF-8        LC_COLLATE=fr_FR.UTF-8     LC_MONETARY=fr_FR.UTF-8   
 [6] LC_MESSAGES=fr_FR.UTF-8    LC_PAPER=fr_FR.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.4.4  backports_1.1.2 magrittr_1.5    rprojroot_1.3-2 htmltools_0.3.6 tools_3.4.4     yaml_2.1.18     Rcpp_0.12.16    stringi_1.1.7  
[10] rmarkdown_1.9   knitr_1.20      stringr_1.3.0   digest_0.6.15   evaluate_0.10.1

您的
etude.cls
模板在与截面单位关联的命令定义中有许多(不需要的)假空格。具体来说,您必须添加行尾注释字符
%
,以避免在需要未编号部分时丢失
*
。以下是您需要更新的内容:

\renewcommand{\section}{
    \@startsection{section}{1}{0pt}
    {-3.5ex plus -1ex minus -.2ex}
    {2.3ex plus.2ex}
    {\color{\SectionTitleColor}\normalfont\Large\bfseries}% <---- comment character added
  %{\color{TextColor}\normalfont\Large\bfseries}
}
\renewcommand\subsection{
    \@startsection{subsection}{2}{\z@}
      {-3.25ex\@plus -1ex \@minus -.2ex}
    {1.5ex \@plus .2ex}
    {\color{\SectionTitleColor}\normalfont\large\bfseries}% <---- comment character added
  %{\color{TextColor}\normalfont\large\bfseries}
}
\renewcommand\subsubsection{
      \@startsection{subsubsection}{3}{\z@}
      {-3.25ex\@plus -1ex \@minus -.2ex}
      {1.5ex \@plus .2ex}
      {\color{\SectionTitleColor}\normalfont\normalsize\bfseries}% <---- comment character added
    %{\color{TextColor}\normalfont\normalsize\bfseries}
}
\renewcommand\paragraph{
      \@startsection{paragraph}{4}{\z@}
      {-3.25ex\@plus -1ex \@minus -.2ex}
      {-1em}
      {\color{\SectionTitleColor}\normalfont\normalsize}% <---- comment character added
    %{\color{TextColor}\normalfont\normalsize}
}
\renewcommand\subparagraph{
      \@startsection{subparagraph}{5}{\z@}
      {-3.25ex\@plus -1ex \@minus -.2ex}
      {-1em}
      {\color{\SectionTitleColor}\normalfont\normalsize}% <---- comment character added
    %{\color{TextColor}\normalfont\normalsize}
}
\renewcommand{\section}{
\@startsection{section}{1}{0pt}
{-3.5ex加-1ex减-0.2ex}
{2.3ex plus.2ex}

{\color{\SectionTitleColor}\normalfont\Large\bfseries}%Open
etude.cls
并找到重新定义
\section
\subsection
,…的区域。然后在定义末尾添加注释字符
%
(如中)。看看这是否能解决您的问题。@Werner,事实上能解决!非常感谢!我不明白为什么会这样,但它确实解决了。我在
etude.cls
中建议使用一个自定义节标题的旁路,该标题改编自mySection宏,但@Werner的解决方案是一个真正的解决方案,而且更加优雅,所以…我如何解决这个问题(如此新手)?我已为您的问题添加了答案。您可以对其进行投票,并通过单击投票按钮下方的复选标记接受is作为正确答案。感谢您的解释,我自己不会找到它。这是我从另一所大学借用的模板,我制作了一个弗兰肯斯坦怪物。我无法投票(没有足够的代表点数)但这是正确的答案。:)