From 4ca64b7b9f17cdc5b81f9773bc3dbb1e1e57a314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=AA=E6=98=8E?= <niming@usst.edu.cn> Date: Mon, 30 Sep 2024 07:06:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0draftmode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sustech-setup.tex | 38 +++++++++++++++++++++++++++++++- sustechthesis-example-report.tex | 1 + sustechthesis-example.tex | 1 + 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/sustech-setup.tex b/sustech-setup.tex index 4a07c57..eb405f9 100644 --- a/sustech-setup.tex +++ b/sustech-setup.tex @@ -201,4 +201,40 @@ \newcommand\undefcolumntype[1]{\expandafter\let\csname NC@find@#1\endcsname\relax} -\newcommand\forcenewcolumntype[1]{\undefcolumntype{#1}\newcolumntype{#1}} \ No newline at end of file +\newcommand\forcenewcolumntype[1]{\undefcolumntype{#1}\newcolumntype{#1}} + + + +% 定义draft模式的条件 +\newif\ifdraftmode +\draftmodefalse % 默认关闭draft模式 + +% 定义一个命令来开启draft模式 +\newcommand{\enabledraftmode}{% + \draftmodetrue + \PassOptionsToPackage{draft}{graphicx} + \PassOptionsToPackage{draft}{hyperref} + \ifdefined\oldincludegraphics\else + \let\oldincludegraphics\includegraphics + \fi + \renewcommand{\includegraphics}[2][]{% + \begingroup + \def\draftimagearg{##2}% + \def\draftimageopts{##1}% + \sbox0{\oldincludegraphics[##1]{##2}}% + \fbox{\parbox[c][\ht0]{\wd0}{\centering Draft Image:\\\texttt{\draftimagearg}}}% + \endgroup + } + \overfullrule=5pt % 显示溢出的箱子 +} + +% 定义一个命令来关闭draft模式(如果需要的话) +\newcommand{\disabledraftmode}{% + \draftmodefalse + \PassOptionsToPackage{final}{graphicx} + \PassOptionsToPackage{final}{hyperref} + \ifdefined\oldincludegraphics + \let\includegraphics\oldincludegraphics + \fi + \overfullrule=0pt +} \ No newline at end of file diff --git a/sustechthesis-example-report.tex b/sustechthesis-example-report.tex index b16375f..36bd24b 100644 --- a/sustechthesis-example-report.tex +++ b/sustechthesis-example-report.tex @@ -32,6 +32,7 @@ % 5. 作者姓名、指导教师等 \input{sustech-setup} +% \enabledraftmode % 启用草稿模式,会以文字占位符替代图片,加快大量插入大尺寸图片时的编译速度,用于学位论文的调试,默认不启用 \begin{document} diff --git a/sustechthesis-example.tex b/sustechthesis-example.tex index db08dd4..b81832f 100644 --- a/sustechthesis-example.tex +++ b/sustechthesis-example.tex @@ -32,6 +32,7 @@ % 5. 修改degree-type的值, 默认academic代表生成学术型研究生毕业设计模板, 改为professional则将生成专业型研究生毕业设计模板。 \input{sustech-setup} +% \enabledraftmode % 启用草稿模式,会以文字占位符替代图片,加快大量插入大尺寸图片时的编译速度,用于学位论文的调试,默认不启用 \begin{document}