Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document开启twoside时,listoffigures与listoftables出现显示错误 #944

Closed
Fang-Haoshu opened this issue May 17, 2023 · 15 comments
Closed
Labels

Comments

@Fang-Haoshu
Copy link

问题描述:
在document默认开启twoside时,英文版listoffigures与listoftables会出现如图所示的错位显示:
image
刚开始以为是subfigure与tocloft冲突导致,切换回subcaption发现还是有此问题,最后开启oneside后该问题消失

系统信息:

  • OS版本(带版本号): sjtu的官方latex网站
  • TeX 发行版(带版本号): XeLatex

日志信息:

日志信息附于附件中

output.log

-->

@LogCreative
Copy link
Contributor

LogCreative commented May 18, 2023

可能是没有清理临时文件所致?

@Fang-Haoshu
Copy link
Author

Fang-Haoshu commented May 18, 2023

应该不是,刚刚尝试了一下清理缓存文件重新编译,在开启twoside的时候还是会出现这个显示bug

@LogCreative
Copy link
Contributor

从日志文件来看,仍然引入了 subfigure 宏包,有没有尝试过完全去除 \usepackage{subfigure},以及我本地引入 subfigure 时,实际上是编译不成功的:

Package subcaption Error: This package can't be used in cooperation
(subcaption)                with the subfigure package.

@Fang-Haoshu
Copy link
Author

谢谢你对这个问题的关注!是的,后来也尝试了一下只使用subcaption,log如下,问题似乎还是存在,我附上了一个最小可复现环境,应该导入sjtu latex,用xelatex编译就能复现,不知道是不是我哪里搞bug了
output (2).log

MWE.zip

@LogCreative
Copy link
Contributor

LogCreative commented May 21, 2023

复现了这个 bug,触发条件:

  1. 第一个标题大于等于3行
  2. 使用双页模式
  3. 插图索引大于1页
\documentclass{sjtuthesis}
\begin{document}
    \frontmatter
    \listoffigures*

    \mainmatter
    \chapter{Test}
    
    \ExplSyntaxOn
    \int_step_inline:nn{10}{
    \begin{figure}
        % \caption{This~is~a~super~long~caption~that~needs~attention~in~the~list~of~figures~to~see~if~there~is~some~vertical~overflow.}
        \caption{这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题}
    \end{figure}
    }
    \ExplSyntaxOff
\end{document}

cc @AlexaraWu

@LogCreative
Copy link
Contributor

当然最好的实践应该是每个图标题设定一个简短的标题放在插图索引中。

\caption[简短的标题]{这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题}

@AlexaraWu
Copy link
Collaborator

试了一下用 ctexbook 是正常的,还不清楚是哪里的问题,有空我排查一下。

@Fang-Haoshu
Copy link
Author

当然最好的实践应该是每个图标题设定一个简短的标题放在插图索引中。

\caption[简短的标题]{这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题}

有道理

@AlexaraWu
Copy link
Collaborator

AlexaraWu commented Sep 23, 2023

初步排查应该和 ctex\chapter\fixskip 选项相关,关闭此选项后没有问题。

@AlexaraWu
Copy link
Collaborator

更正:此问题与页面纵向对齐方式有关,标准文档类中 oneside 默认开启 \raggedbottom,手动开启 \flushbottom 也可以复现此问题。

建议修改模板 onesidetwoside 均默认使用 \raggedbottom

\documentclass[oneside]{sjtuthesis}

\flushbottom

\begin{document}

\frontmatter

\listoffigures

\mainmatter

\chapter{测试}

\ExplSyntaxOn
\int_step_inline:nn { 10 }
  {
    \begin{figure}
      \caption{这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题}
    \end{figure}
  }
\ExplSyntaxOff

\end{document}

@AlexaraWu
Copy link
Collaborator

AlexaraWu commented Sep 23, 2023

fixskip 应该还是有点关系的,实测 \parskip=0pt 取消段间距的弹性也可以解决这个问题。推测是 fixskip 在章标题中引入了弹性间距,在 \flushbottom 模式下产生了问题。

@LogCreative
Copy link
Contributor

LogCreative commented Sep 23, 2023

试了一下普通的 itemize 是没问题的。最后发现是 \l@figure(被 tocloft 宏包重定义) 中关于 \interlinepenalty 的问题:

展开
\documentclass{sjtuthesis}

\makeatletter
\def\l@figure#1#2{
  \ifnum \c@lofdepth >\z@ 
  \vskip \cftbeforefigskip
  {
  \leftskip \cftfigindent \relax \rightskip \@tocrmarg \parfillskip -\rightskip
  \parindent \cftfigindent \relax \@afterindenttrue
  \interlinepenalty \@M      % <-- 注释这一行变为正常
  \leavevmode \@tempdima \cftfignumwidth \relax \let \@cftbsnum \cftfigpresnum
  \let \@cftasnum \cftfigaftersnum \let \@cftasnumb \cftfigaftersnumb \advance
  \leftskip \@tempdima \null \nobreak \hskip -\leftskip {\cftfigfont #1}\nobreak
  \cftfigfillnum {#2}
  }
  \fi
}

\begin{document}

\frontmatter

\listoffigures

\mainmatter

\makeatletter
\SJTU@head*{测试}
\makeatother

\begin{itemize}
\ExplSyntaxOn
\int_step_inline:nn { 10 }
  {
    \item[图1-1]
      这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题\par\vskip1ex plus 5pt minus 5pt
  }
\ExplSyntaxOff
\end{itemize}

\chapter{测试2}

\ExplSyntaxOn
\int_step_inline:nn{10}{
\begin{figure}
    % \caption{This~is~a~super~long~caption~that~needs~attention~in~the~list~of~figures~to~see~if~there~is~some~vertical~overflow.}
    \caption{这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题这是一个超级长的标题}
\end{figure}
}
\ExplSyntaxOff

\end{document}

@LogCreative
Copy link
Contributor

LogCreative commented Sep 23, 2023

\@M10000,如果把这行改为 \interlinepenalty 9849 就是正常, \interlinepenalty 9850 就是异常。

@LogCreative
Copy link
Contributor

这是为了阻止每个项目内部的断页,应该跟这个问题没关

@AlexaraWu
Copy link
Collaborator

fixed in v2.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants