SchoolWork-LaTeX/计算机网络/平时作业/mypreamble.tex
423A35C7 5906ac1efc 重构目录层次
0-课程笔记
1-平时作业
2-实验报告
3-期末大作业
2024-09-02 18:32:58 +08:00

145 lines
3.5 KiB
TeX
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

\usepackage[margin=1in]{geometry}
\usepackage{environ} % 加了这个再\def\myitem就不报错了
\usepackage{extarrows}
\usepackage{enumerate}
\usepackage{enumitem}
\usepackage{amssymb, amsfonts, amstext, amsmath, amsopn, amsthm}
\usepackage{extarrows}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{array}
\usepackage{ragged2e}
\usepackage[outputdir=./latex-output]{minted}
\usepackage{color}
\usepackage{hyperref}
\usepackage{mylatex}
\usepackage{subfiles}
\setlist[1]{label=P\arabic{enumi}.,listparindent=\parindent}
\setlist[2]{label=\alph{enumii}.,listparindent=\parindent}
\definecolor{shadecolor}{RGB}{204,232,207}
% 有\EnumitemId了
% 百分号要记得在判断语句的外面也用上
\def\getenum{%
\ifnum\EnumitemId=1%
enumi%
\else
\ifnum\EnumitemId=2%
enumii%
\else
\ifnum\EnumitemId=3%
enumiii%
\else%
enumiv%
\fi
\fi
\fi%
}
% \ifx\theenumiv\empty
% \ifx\theenumiii{}
% \ifx\theenumii{}
% 1
% \else
% 2
% \fi
% \else
% 3
% \fi
% \else
% 4
% \fi
% 可选参数合并到主.sty文件中了
% \def\myitemArg#1#2{
% \item \textbf{#1}
% \begin{enumerate}
% #2
% \end{enumerate}
% }
% \def\myitemOptArg[#1]#2#3{
% \setcounter{\getenum}{#1-1}
% \item \textbf{#2}
% \begin{enumerate}
% #3
% \end{enumerate}
% }
% \def\myitem{\futurelet\next\myitemAux}
% \def\myitemAux{\ifx\next[%
% \expandafter\myitemOptArg
% \else
% \expandafter\myitemArg
% \fi}
% \def\originitem{\csname\item \endcsname}
% \edef\item[#1]{
% \csname a\expandafter \endcsname \item
% % {\setcounter{\getenum}{#1-1}}
% % {\item}
% }
% \edef\item{\item}
% \edef\item{\originitem}
\newcommand{\cnitem}[1][]{
\IfBlankF{#1}{
\setcounter{\getenum}{#1-1}
}
\item
}
% 好像直接\AddEnumerateCounter就行
\newcommand{\questionandanswer}[3][]{%
\begin{shaded}%
\ifstrequal{#1}{-}{}{\cnitem[#1]} #2%
\end{shaded}%
\begin{zhongwen}%
#3%
\end{zhongwen}%
}
\ExplSyntaxOn
\cs_set:Nn \rawquestionandanswer:Nnnn {%
\begin{shaded}%
\ifstrequal{#2}{-}{}{\format_item:Nn #1{#2}} #3%
\end{shaded}%
\begin{zhongwen}%
#4%
\end{zhongwen}%
}
\cs_set:Nn \format_item:Nn {
\IfBlankTF{#2}{
\stepcounter{\getenum}
\item[#1{\csname the\getenum\endcsname}]
% 完美结合了LaTeX2e和LaTeX3
}{
\item[#1{#2}]
}
}
\cs_set:Nn \Rformat:n {R#1.}
\cs_set:Nn \Pformat:n {P#1.}
\newcommand{\Rquestionandanswer}[3][]{%
\rawquestionandanswer:Nnnn \Rformat:n {#1}{#2}{#3}
}
\newcommand{\Pquestionandanswer}[3][]{%
\rawquestionandanswer:Nnnn \Pformat:n {#1}{#2}{#3}
}
\ExplSyntaxOff
% 成功实现了,而且下划线也没问题!!!似乎是函数式程序设计,或者装饰器模式?
% 该命令用于控制 p{} 的情况
\newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}p{#1}} % 使用过程中将p{4cm}换成P{4cm},小写改成大写即可!
% 该命令用于控制 X 的情况
\newcolumntype{Z}{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}X} % 使用过程中将Z 换成 X即可
% 可利用 RaggedLeft Centering替换RaggedRight实现靠右和居中 [代码对大小写敏感!!!!!!!!!!!!!!!!!!!!!!!!!!!!]
% 原文链接https://blog.csdn.net/wanjiac/article/details/107494424