Skip to content

Instantly share code, notes, and snippets.

@zorchp
Last active December 2, 2023 12:33
Show Gist options
  • Save zorchp/77f3bb179015820c84e367e578e50314 to your computer and use it in GitHub Desktop.
Save zorchp/77f3bb179015820c84e367e578e50314 to your computer and use it in GitHub Desktop.
Some useful snippets for LaTeX typewriting including Article, Beamer, TikZ Picture and so on.
%%%%%%%%%%%%%%%%%%% 参考文献 %%%%%%%%%%%%%%%%%%%%%%
% 自定义新命令\upcite, 使参考文献引用以上标出现
\newcommand{\upcite}[1]{\textsuperscript{\cite{#1}}}
% 参考文献样式
\bibliographystyle{data/gbt7714-2005}
%%% 目录设置
\usepackage{tocloft}
\setcounter{tocdepth}{2} % 目录层级数
\setcounter{secnumdepth}{3} % 标题层级数
% 调整目录的行距
\setlength\cftbeforechapskip{0em}
\setlength\cftbeforesecskip{0em}
\setlength\cftbeforesubsecskip{0em}
% \renewcommand\cftparskip{.1em}
% 目录条目行首缩进值
\setlength{\cftsecindent}{2em}
\setlength{\cftsubsecindent}{4em}
\setlength{\cftsubsubsecindent}{6em}
%%%%%%%%%%%%% 表格 %%%%%%%%%%%%%%%%%%
% 使用tabularx创建占满宽度的表格
\usepackage{tabularx, makecell}
\newcolumntype{C}{>{\centering \arraybackslash}X}
\newcolumntype{R}{>{\raggedleft \arraybackslash}X}
\usepackage{longtable} % 做长表格的包
\usepackage{booktabs} % 做三线表的包
\usepackage{diagbox}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 公式, 字体, 字号等 %%%%%%%%%%%%%%%%%%%%%%%
%% beamer尾页
\begin{frame}
%\sffamily
\begin{center}
{\textcolor[RGB]{165,3,3}{\fontsize{60}{0}\selectfont
% 谢\quad 谢! \\[8pt]
Thank you!}}
\end{center}
\end{frame}
% 设置公式的编号为短杠形式
\renewcommand\theequation{%
\thechapter-\arabic{equation}}
% 设置图, 表的编号为短杠形式
\renewcommand\thefigure{\arabic{chapter}-\arabic{figure}}
\renewcommand\thetable{\arabic{chapter}-\arabic{table}}
% 允许跨页公式
\allowdisplaybreaks
% Times 风格(数学)字体
\usepackage{txfonts}
% 设置英文字体为 Times New Roman
\setmainfont[Ligatures=Rare]{Times New Roman}
\setsansfont[Ligatures=Rare]{Times New Roman}
\setmonofont[Ligatures=Rare]{Times New Roman}
% 字体:
% 这里使用了字体名称, Windows用户需要右键执行`为所有用户安装`, MacOS直接安装即可.
%使用STXingkai华文行楷字体
\setCJKfamilyfont{hwxk}{华文行楷}
\newcommand{\huawenxingkai}{\CJKfamily{hwxk}}
% 方正仿宋简体
\setCJKfamilyfont{fangzheng}{方正仿宋简体}
\newcommand{\fangzheng}{\CJKfamily{fangzheng}}
% 重定义黑体为中易黑体: SimHei
\setCJKfamilyfont{msheiti}{SimHei}
\renewcommand{\heiti}{\CJKfamily{msheiti}}
% 宋体
\setCJKfamilyfont{simsun}{SimSun}
\renewcommand{\songti}{\CJKfamily{simsun}}
% 楷体_GB2312
\setCJKfamilyfont{kaigb}{楷体_GB2312}
\newcommand{\kaigb}{\CJKfamily{kaigb}}
\setCJKfamilyfont{times}{Times New Roman}
\newcommand{\timen}{\CJKfamily{times}}
%% Only for MacOS
\setmainfont{Times New Roman}%缺省英文字体 Times New Roman
\setCJKmainfont{STSong}%衬线字体 缺省中文字体为
\setCJKsansfont{STHeitiSC-Light}%serif是有衬线字体sans serif无衬线字体。
\setCJKmonofont{STFangsong}%中文等宽字体
%% Only for Windows
\setmainfont{Times New Roman}%缺省英文字体 Times New Roman
\setCJKmainfont{SimSun}%衬线字体 缺省中文字体为
\setCJKsansfont{SimHei}%serif是有衬线字体sans serif无衬线字体。
%\setCJKmonofont{Fangsong}%中文等宽字体
\newcommand{\chuhao}{\fontsize{42pt}{1.25\baselineskip}\selectfont} %初号
\newcommand{\xiaochuhao}{\fontsize{36pt}{1.25\baselineskip}\selectfont} %小初号
\newcommand{\yihao}{\fontsize{28pt}{1.25\baselineskip}\selectfont} %一号
\newcommand{\erhao}{\fontsize{21pt}{1.25\baselineskip}\selectfont} %二号
\newcommand{\xiaoerhao}{\fontsize{18pt}{1.25\baselineskip}\selectfont} %小二号
\newcommand{\sanhao}{\fontsize{15.75pt}{1.25\baselineskip}\selectfont} %三号
\newcommand{\sihao}{\fontsize{14pt}{1.25\baselineskip}\selectfont}% 四号
\newcommand{\xiaosihao}{\fontsize{12pt}{1.25\baselineskip}\selectfont} %小四号
\newcommand{\wuhao}{\fontsize{10.5pt}{1.25\baselineskip}\selectfont} %五号
\newcommand{\xiaowuhao}{\fontsize{9pt}{1.25\baselineskip}\selectfont} %小五号
\newcommand{\liuhao}{\fontsize{7.875pt}{1.25\baselineskip}\selectfont} %六号
\newcommand{\qihao}{\fontsize{5.25pt}{1.25\baselineskip}\selectfont} %七号
%% 设置beamer 展示每章节开头都有目录标识(渐隐)
\AtBeginSection[]
{
\begin{frame}{目录}
\transfade %淡入淡出效果
\tableofcontents[sectionstyle=show/shaded,subsectionstyle=show/shaded/hide]
\addtocounter{framenumber}{-1} %目录页不计算页码
\end{frame}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment