Skip to content

Commit

Permalink
Merge pull request #54 from SUSTech-CRA/fix/fig-tab-sep
Browse files Browse the repository at this point in the history
同步上游关于图表距离的修复
  • Loading branch information
liziwl authored Apr 14, 2022
2 parents 64e02f8 + 996c01e commit 3cca3bf
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 11 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Changelog 维护应保持最新版本在文件上面的原则,日期格式按
## [Unreleased](https://github.com/SUSTech-CRA/sustech-master-thesis/compare/v1.3.13...HEAD)

### Changed
- 允许论文题目和章节题目出现特殊的小写字母

- 允许论文题目和章节题目出现特殊的小写字母
- 同步上游关于图表距离的修复,浮动对象整体上下距离调整为12bp。

## [1.3.13](https://github.com/SUSTech-CRA/sustech-master-thesis/compare/v1.3.12...v1.3.13)
### Added
Expand Down
36 changes: 36 additions & 0 deletions data/chap02.tex
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,39 @@ \section{伪代码}
$\Delta B^{\ast}\leftarrow \Delta B$\;}
$r\leftarrow r+1$\;}
\end{algorithm}

\newpage
\section{测试}

图题在图之下,段前空 6 磅,段后空 12 磅。图整体前后距离未定义,目前默认距离:段前空 12 磅,段后空 12 磅。

图前,图前,图前,图前,图前,图前,图前,图前,图前,图前,图前。

\begin{figure}[htbp]
\centering
\includegraphics[height=12bp,width=50bp]{example-image-a.pdf}\hspace*{6bp}
\includegraphics[height=6bp,width=50bp]{example-image-a.pdf}
\caption{图高度为12bp vs 6bp}
\end{figure}

图后,图后,图后,图后,图后,图后,图后,图后,图后,图后,图后。

表题在表之上,段前空 12 磅,段后空 6 磅。表整体前后距离未定义,目前默认距离:段前空 12 磅,段后空 12 磅。

表前,表前,表前,表前,表前,表前,表前,表前,表前,表前,表前。

\begin{table}[htbp]
\centering
\caption{简单表格}
\begin{tabular}{cc}
\toprule
column1 & column2\\
\midrule
column1 & column2\\
\bottomrule
\end{tabular}
\label{label}
\end{table}

表后,表后,表后,表后,表后,表后,表后,表后,表后,表后,表后。
\emph{图表前后是否有空行不影响图表与正文之间的距离}。
2 changes: 1 addition & 1 deletion sustech-setup.tex
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@
% W 右对齐
\newcolumntype{W}{>{\raggedleft\arraybackslash}X}
% Z 居中对齐
\newcolumntype{Z}{>{\centering\arraybackslash}X}
\newcolumntype{Z}{>{\centering\arraybackslash}X}
47 changes: 39 additions & 8 deletions sustechthesis.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -2639,20 +2639,53 @@
%
% 图表浮动体的默认位置设为 |h|。
% \begin{macrocode}
\def\fps@figure{h}
\def\fps@table{h}
\def\fps@figure{htbp}
\def\fps@table{htbp}
% \end{macrocode}
%
% 设置浮动对象和文字之间的距离
% \begin{macrocode}
\setlength{\floatsep}{6bp}
\setlength{\textfloatsep}{6bp}
\setlength{\intextsep}{6bp}
\setlength{\floatsep}{12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength{\textfloatsep}{12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength{\intextsep}{12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength{\@fptop}{0bp \@plus1.0fil}
\setlength{\@fpsep}{12bp \@plus2.0fil}
\setlength{\@fpbot}{0bp \@plus1.0fil}
% \end{macrocode}
%
% 由于 LaTeX2e kernel 的问题,图表等浮动体与文字前后的距离不一致,需要进行 patch。
% 参考 \href{https://github.com/tuna/thuthesis/issues/614}{tuna/thuthesis/issues\#614}、
% \url{https://www.zhihu.com/question/46618031} 和
% \url{https://tex.stackexchange.com/a/40363/82731}。
% \begin{macrocode}
\patchcmd{\@addtocurcol}%
{\vskip \intextsep}%
{\edef\save@first@penalty{\the\lastpenalty}\unpenalty
\ifnum \lastpenalty = \@M % hopefully the OR penalty
\unpenalty
\else
\penalty \save@first@penalty \relax % put it back
\fi
\ifnum\outputpenalty <-\@Mii
\addvspace\intextsep
\vskip\parskip
\else
\addvspace\intextsep
\fi}%
{}{\thu@patch@error{\@addtocurcol}}
\patchcmd{\@addtocurcol}%
{\vskip\intextsep \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi}%
{\ifnum\outputpenalty <-\@Mii
\aftergroup\vskip\aftergroup\intextsep
\aftergroup\nointerlineskip
\else
\vskip\intextsep
\fi}%
{}{\thu@patch@error{\@addtocurcol}}
\patchcmd{\@getpen}{\@M}{\@Mi}
{}{\thu@patch@error{\@getpen}}
% \end{macrocode}
%
% 下面这组命令使浮动对象的缺省值稍微宽松一点,从而防止幅度对象占据过多的文本页面,
% 也可以防止在很大空白的浮动页上放置很小的图形。
% \begin{macrocode}
Expand Down Expand Up @@ -2703,10 +2736,8 @@
skip = 6bp,
figureposition = bottom,
tableposition = top,
justification = centering
justification = centering,
}
\captionsetup[figure]{belowskip=12bp}
\captionsetup[table]{belowskip=12bp}
\captionsetup[sub]{font=thu}
% \end{macrocode}
%
Expand Down

0 comments on commit 3cca3bf

Please sign in to comment.