Skip to content
New issue

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

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

Already on GitHub? # to your account

建议\institute{}和\advisors{}增加换行功能 #190

Closed
Pantrick opened this issue Sep 30, 2019 · 11 comments
Closed

建议\institute{}和\advisors{}增加换行功能 #190

Pantrick opened this issue Sep 30, 2019 · 11 comments

Comments

@Pantrick
Copy link

由于中科院某些所的改名,现在有些所系的名字特别长,一行已经写不下了。
我现在的解决方案是自行在ucasthesis.cls中添加了\advisorss\institutes命令,并改变了首页的部分结构,如果需要更多行数,可以继续添加诸如\advisorsss,但是破坏了模板的某些自洽性。

\def\ucas@value@ch@advisorss{}
\newcommand{\advisorss}[1]{\def\ucas@value@ch@advisorss{#1}}
\def\ucas@value@ch@institutes{}
\newcommand{\institutes}[1]{\def\ucas@value@ch@institutes{#1}}

Snipaste_2019-09-30_11-42-08

希望作者可以想办法将\institute{}\advisors{}增加换行功能,以兼容更长的所系名字。

(这是某些所作妖,与我们学生何关 ( : P))

@mohuangrui
Copy link
Owner

这个是官方要求的吗?感觉可能不太符合国科大的标准吧,根据国科大撰写规范:
“7. 培养单位
填写就读研究所或学院全称,如中国科学院 XX 研究所、中国科学院大学 XX 学院。”

虽然有很直接的实现方法,但因为表格环境限制较多,想要改的简洁明了,却也不太容易。所以,我再观望一阵吧

@Pantrick
Copy link
Author

Pantrick commented Oct 7, 2019

这是近几年新的要求,确实很麻烦,差点我就换word写了。
我贴一下我的完整解决方案,供其他同学参考。
ucasthesis.cls的194行左右添加

\def\ucas@value@ch@advisorss{}
\newcommand{\advisorss}[1]{\def\ucas@value@ch@advisorss{#1}}
\def\ucas@value@ch@institutes{}
\newcommand{\institutes}[1]{\def\ucas@value@ch@institutes{#1}}

ucasthesis.cls的293行左右修改

\begin{tabular}{lc}
\ucas@label@ch@author & \ulenhance[1.2pt]{\ulextend{\ucas@value@ch@author}}\\
\ucas@label@ch@advisor & \ulenhance[1.2pt]{\ulextend{\ucas@value@ch@advisor}}\\
& \ulenhance[1.2pt]{\ulextend{\ucas@value@ch@advisors}}\\
\ucas@label@ch@degree & \ulenhance[1.2pt]{\ulextend{\ucas@value@ch@degreetype\ucas@value@ch@degree}}\\
\ucas@label@ch@major & \ulenhance[1.2pt]{\ulextend{\ucas@value@ch@major}}\\
\ucas@label@ch@institute & \ulenhance[1.2pt]{\ulextend{\ucas@value@ch@institute}}\\
\end{tabular}

        \begin{tabular}{lc}
            \ucas@label@ch@author & \ulenhance[1.2pt]{\ulextend{\ucas@value@ch@author}}\\
            \ucas@label@ch@advisor & \ulenhance[1.2pt]{\ulextend{\ucas@value@ch@advisor}}\\
            & \ulenhance[1.2pt]{\ulextend{\ucas@value@ch@advisors}}\\
            & \ulenhance[1.2pt]{\ulextend{\ucas@value@ch@advisorss}}\\ %这行是新添加的
            \ucas@label@ch@degree & \ulenhance[1.2pt]{\ulextend{\ucas@value@ch@degreetype\ucas@value@ch@degree}}\\
            \ucas@label@ch@major & \ulenhance[1.2pt]{\ulextend{\ucas@value@ch@major}}\\
            \ucas@label@ch@institute & \ulenhance[1.2pt]{\ulextend{\ucas@value@ch@institute}}\\
            & \ulenhance[1.2pt]{\ulextend{\ucas@value@ch@institutes}}\\ %这行是新添加的
        \end{tabular}

最后在Frontinfo.tex中添加两行

\confidential{}% 密级:只有涉密论文才填写
\schoollogo[scale=0.095]{ucas_logo}% 校徽
\title{中国科学院大学学位论文\LaTeX{}模板 {$~^{\pi}\pi^{\pi}$}}% 论文中文题目
\author{莫晃锐}% 论文作者
\advisor{刘青泉~研究员~中国科学院力学研究所}% 指导教师:姓名 专业技术职务 工作单位
\advisors{}% 指导老师附加信息 或 第二指导老师信息
\degree{硕士}% 学位:学士、硕士、博士
\degreetype{理学}% 学位类别:理学、工学、工程、医学等
\major{流体力学}% 二级学科专业名称
\institute{中国科学院力学研究所}% 院系名称
\date{2014~年~6~月}% 毕业日期:夏季为6月、冬季为12月

\advisorss{\hspace{+0.0em}分子细胞科学卓越创新中心}
\institutes{\hspace{+0.0em}分子细胞科学卓越创新中心}

就可以让导师信息和培养单位分别多出一行,缺点是必须多出这两行,与原来的模板不兼容了。
最好就是希望ucasthesis.clstabular环境中可以有一些判别条件,可以根据Frontinfo.tex的信息自适应的改变格式。

@mohuangrui
Copy link
Owner

是的,需要自适应才行,我等有时间时改改看

@muzimuzhi
Copy link
Contributor

muzimuzhi commented Oct 10, 2019

我在提交 https://github.com/muzimuzhi/ucasthesis/commit/253b649f330588942e03938f8e8237a33989e30b 里做了一个实现,主要改动是

  • 允许 \advisors\institute 接受多行的参数,新用法为 \advisors{a\\b\\c}
  • 新定义宏 \ucas@titlepage@formatter,生成 \format{a} \\ & \format{b} \\ & \format{c} 形式的输出,这里的 \format 可以是任意的宏

测试例子:
输入

\advisors{老师1\\老师2}
\institute{中国科学院力学研究所 \\ abc}

输出
image


PS:

  • 实现里用了 latex3 提供的函数,因为处理列表时用 latex3 写起来最方便,也不用额外增加依赖,expl3 宏包已经在 ctexbook 文档类里引入了。不是为了 latex3 而用 latex3,而是不得不用。etoolbox 提供了循环处理列表每一项的命令,但是没有提供「在相邻两项之间插入内容,对应 latex3 里的 \clist_use:Nn」的命令。
  • 有了这个实现,感觉可以把 \advisor\advisors 合并为一个。

@Pantrick
Copy link
Author

用xelatex测试了一下,可以。

@mohuangrui
Copy link
Owner

@muzimuzhi 我在 Windows Miktex

(This is XeTeX, Version 3.14159265-2.6-0.999991 (MiKTeX 2.9.7050 64-bit)
entering extended mode LaTeX2e <2018-12-01>)

和 Ubuntu texlive

(This is XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017/Debian) (preloaded format=xelatex) LaTeX2e <2017-04-15>)

上测试,出现错误:

The comma list \l_tmpb_clist contains the items (without outer braces):
>  {\ulenhance [1.2pt]{\ulextend {老师1}}}
>  {\ulenhance [1.2pt]{\ulextend {老师2}}}.
<recently read> }
                 
l.8 \MAKETITLE
              % 生成英文封面

可以解决吗?

@muzimuzhi
Copy link
Contributor

这不是错误,是输出的调试信息。
\clist_show:N\l_tmpb_clist 这一行注释即可,参考提交 https://github.com/muzimuzhi/ucasthesis/commit/677a59acd4181c89e6a961453b56e5400ea2dbe5

@mohuangrui
Copy link
Owner

mohuangrui commented Oct 11, 2019

@muzimuzhi 测试效果非常理想,已 merge,非常感谢~

@mohuangrui
Copy link
Owner

@Pantrick @muzimuzhi 模板已更新完毕,合并了 \advisor 和 \advisors。

同时细微调整了下 @muzimuzhi 的命令参数:

\newcommand{\ucaslntotab}[2][1pt]{% convert lines into table lines

@muzimuzhi 再次感谢你的帮助~

@muzimuzhi
Copy link
Contributor

@muzimuzhi 功能很强 我有个问题 \ulextend{##1} 的默认参数可以再次传入么?

看起来是个单独的新问题,发新 issue?

@mohuangrui
Copy link
Owner

@muzimuzhi 增加一个变量,套一个长度变量。其他人没有问题我也就不要求了。

现在的一些人是怎么了,请人帮忙回答/解决问题像是大爷在提要求?在开源社区,大家都是凭着热情自愿帮忙,每个人的时间都很珍贵。若不尊重他人的时间和付出,用大爷的口吻提不得其要的问题,请移步他处。

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants