stone-zeng / fduthesis

LaTeX thesis template for Fudan University
LaTeX Project Public License v1.3c
811 stars 205 forks source link

关于使用 \fdusetup 参数列表不能出现空行的问题 #298

Closed djunhao closed 1 year ago

djunhao commented 1 year ago

描述问题

曾老师在文档中提及:

fdusetup 采用 LaTeX3 风格的键值设置,支持不同类型以及多种层次的选项设定。键值列表中,“=”左右的空格不影响设置;但需注意,参数列表中不可以出现空行

我在编写个人使用的文档类时,也发现了这个问题。一旦在文档中导言区出现空行的话,编译就会出错。我用曾老师的fduthesis来构建一个例子:

\documentclass{fduthesis}
\fdusetup{
    style = {cjk-font = adobe, font-size = -4},
    info  = {
      title      = {论动体的电动力学},
      title*     = {On the Electrodynamics of Moving Bodies},
      author     = {阿尔伯特·爱因斯坦},
      author*    = {Albert Einstein},
      department = {物理学系}

    }
  }
\begin{document}
\section{测试参数列表空行}
\end{document}

编译就会抛出错误:

 Runaway argument?
 { style = {cjk-font = adobe, font-size = -4}, info = { title = {论动\ETC.
 ./min.tex:11: Paragraph ended before \fdusetup  was complete.
<to be read again> 
                   \par 
l.11 

I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

./min.tex:12: Too many }'s.
l.12     }

You've closed more groups than you opened.
Such booboos are generally harmless, so keep going.

./min.tex:13: Too many }'s.
l.13   }

You've closed more groups than you opened.
Such booboos are generally harmless, so keep going.

经试验,我们可以在应用文档类时加入expl3的语法开关\ExplSyntaxOn来避免因空行导致的编译出错。

\documentclass{fduthesis}
\ExplSyntaxOn
\fdusetup{
    style = {cjk-font = adobe, font-size = -4},

    info  = {
      title      = {论动体的电动力学},
      title*     = {On the Electrodynamics of Moving Bodies},
      author     = {阿尔伯特·爱因斯坦},
      author*    = {Albert Einstein},
      department = {物理学系}

    }
  }
\ExplSyntaxOff
\begin{document}
\section{测试参数列表空行}
\end{document}

这样,我们就不用担心因为无意中打出的空行而出现编译错误了。 当然,这只是权宜之计,希望各位前辈、老师能够给我们提供更加便利的方法来避免这种问题。 谢谢!

编译环境

note286 commented 1 year ago

image

note286 commented 1 year ago

两点:

  1. 空行是没了,空格同样也没了,你的英文标题出现空格怎么办?还不是要加带子,多麻烦。
  2. 为什么要打空行呢,如果你非要空行区分上下两部分,你可以在空行行首加注释符。
djunhao commented 1 year ago

@note286

为什么要打空行呢,如果你非要空行区分上下两部分,你可以在空行行首加注释符。

不是一定要打空行,而是为了防止使用者无意中打出了空行导致编译出错。在我的使用环境中,很多人对latex仅限于使用模板,不会排错

所以,我才说:

这只是权宜之计,希望各位前辈、老师能够给我们提供更加便利的方法来避免这种问题。

note286 commented 1 year ago

很多人对latex仅限于使用模板,不会排错。

不看手册的用户,就不用在乎了。

stone-zeng commented 1 year ago

这个和公式环境一样,都是不允许出现空行的。

当然更好的方法是让 LaTeX3 团队改进一下这里的错误提示(虽然看起来并不是很好办),或者靠 linter 来提示(但也没看多少人用) 。

djunhao commented 1 year ago

这个和公式环境一样,都是不允许出现空行的。

当然更好的方法是让 LaTeX3 团队改进一下这里的错误提示(虽然看起来并不是很好办),或者靠 linter 来提示(但也没看多少人用) 。

错误提示确实不友好。目前看来还是只能在文档中强调不能出现空行了。