From 0796856c0225b70218ff87217c524a5ad09e6e9e Mon Sep 17 00:00:00 2001 From: Rizhong Lin Date: Thu, 25 Apr 2024 18:05:53 +0800 Subject: [PATCH] Add dynamically scaled cover items (#44) * Add dynamically scaled cover items * fix ci * fix ci * fix ci * fix ci * fix ci --- .github/workflows/test.yaml | 4 ++-- style/tongjithesis.cls | 34 ++++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c6cdc7f..949854e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -58,7 +58,7 @@ jobs: - name: install Python for minted uses: actions/setup-python@v4 with: - python-version: "3.9" + python-version: "3.11" - name: pip install Pygments for minted run: pip install Pygments - name: install TeXLive @@ -97,7 +97,7 @@ jobs: - name: install Python for minted uses: actions/setup-python@v4 with: - python-version: "3.9" + python-version: "3.11" - name: pip install Pygments for minted run: pip install Pygments - name: install TeXLive diff --git a/style/tongjithesis.cls b/style/tongjithesis.cls index 008f88b..69ec3fc 100644 --- a/style/tongjithesis.cls +++ b/style/tongjithesis.cls @@ -272,9 +272,9 @@ % 设置参考文献格式 \RequirePackage[ - backend=biber, - style=gb7714-2015, - natbib=true, + backend=biber, + style=gb7714-2015, + natbib=true, ]{biblatex} \addbibresource{bib/note.bib} @@ -294,8 +294,22 @@ \zihao{-3}\oldtabular[#1] }{\renewcommand{\arraystretch}{1.2}\endoldtabular } -\RequirePackage{ulem} -\newcommand{\ulinecentered}[1]{\uline{\makebox[20em][c]{#1}}} + +\RequirePackage{ulem,calc} +\newlength{\covertextwidth} +\newlength{\covermaxwidth} + +\newcommand{\ulinecentered}[1]{ + \setlength{\covertextwidth}{\widthof{#1}} + \setlength{\covermaxwidth}{20em} % Set the maximum width you allow + \ifthenelse{\lengthtest{\covertextwidth > \covermaxwidth}}{ + % Calculate scale factor and scale down text if too wide + \pgfmathsetmacro{\scalefactor}{\covermaxwidth/\covertextwidth} + \uline{\makebox[\covermaxwidth][c]{\scalebox{\scalefactor}[1]{#1}}} + }{ + \uline{\makebox[\covermaxwidth][c]{#1}} % Use normal text if within the limit + } +} % 加载包部分结束,此后开始定义内容 Layout @@ -398,10 +412,10 @@ \makeatletter \def\clearchapterpage{% - \@ifclasswith{tongjithesis}{twoside}{% - \cleardoublepage % 如果使用双面模式的 tongjithesis 文档类,使用 \cleardoublepage 清除页面 - }{% - \clearpage % 否则,使用 \clearpage 清除页面 - } + \@ifclasswith{tongjithesis}{twoside}{% + \cleardoublepage % 如果使用双面模式的 tongjithesis 文档类,使用 \cleardoublepage 清除页面 + }{% + \clearpage % 否则,使用 \clearpage 清除页面 + } } \makeatother \ No newline at end of file