Have you tried?
Editted:
Without zhlineskip
:
With zhlineskip
:
似乎可以实现你想要的1.25
倍行距(?)
Have you tried?
zhlineskip
:zhlineskip
:似乎可以实现你想要的1.25
倍行距(?)
在TL25
中直接使用latexmk -pdfxe
编译确实会出现:
! LaTeX Error: The key 'exam-zh/solution/show-answer' is unknown and is being
(LaTeX) ignored.
For immediate help type H <return>.
...
l.241 }
向上溯源,这个问题报错显然是因为Tl25
自带的v0.2.5
的exam-zh
不认识这个key...
在USTBexam.cls
中,此处写死了solution/show-answer = true,
,是没有考虑到exam-zh
后来的可能更新的...:
% Line 211
\examsetup{
page = {
foot-content = {
\l_ustbexam_title_tl \, 第~\thepage~页 \quad 共~\lastpage@lastpage~页
},
},
sealline = {
show = true,
scope = mod-2,
circle-show = false,
line-type = dotted,
odd-info-content = {{装},{订},{线},{内},{不},{要},{答},{题}},
odd-info-xshift = 12mm,
text = {自觉遵守考试规则,诚信考试,绝不作弊},% \\装订线内不要答题},
text-direction-vertical = true,
text-width = 0.6\textheight,
text-format = \normalfont,
text-xshift = 20mm
},
scoringbox/type = onecolumn,
symbols/change-frac-style = true,
symbols/change-dfrac-style = true,
solution/blank-type = hide,
solution/show-answer = true,
solution/label-content = 解,
question/show-answer = true,
problem/show-answer = true,
paren/show-answer = true,
fillin/show-answer = true,
}
进一步回溯,我们发现OP上传的文件信息为:
\ProvidesExplClass {USTBExam} {2022-11-04} {v2.0} {An exam template for USTB}
开发者在写该.cls
此时大概率使用的是TL23
自带的v0.1.20
前后的版本,我们进一步查看其文档:
由于我没找到v0.1.20
的.pdf
下载链接,用[0.1.23] - 2022-12-20
代替: https://gitee.com/xkwxdyy/exam-zh/releases/download/v0.1.24/exam-zh-doc.pdf
在0.2.0版本之前的文档:
现在TL25
时对应0.2.5的文档:
对于solution/show-answer
这一键值对已经发生了更新...这也是为什么报错的原因。
Remarks:
USTBExam.cls
还有多少mismatch...我不知道,我也没有改的任何动机exam-zh
的v0.1.x
版本,这是USTBExam.cls
没有及时随着exam-zh
更新的问题,理论上,USTBExam-v2.0
从如今来看已经obsoleted,不应该再被使用exam-zh
发生了从v0.1
到v0.2
的破坏性更新,由此产生的版本错配问题自然由下载者负责...USTBExam.cls
已经更新到v2.3
https://github.com/htharoldht/USTBExam/releases/tag/v2.3.0 你可以自行测试关注下是否已经修复,关于模板问题,请向开发者提issues考古... 你提及:
实现图表既在正文提及处显示,又在文末列表汇总显示
egreg在此处使用寄存器保存figure
中的信息,并在文末重新输出:
下面是一个例子:
\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{environ}
\makeatletter
\let\@@figure\figure
\let\@@endfigure\endfigure
\let\figure\@undefined
\let\endfigure\@undefined
\let\@@table\table
\let\@@endtable\endtable
\let\table\@undefined
\let\endtable\@undefined
\newtoks\end@figuretoks
\newtoks\end@tabletoks
\NewEnviron{figure}[1][htp]{%
\@@figure[#1]\BODY\@@endfigure
\global\end@figuretoks=\expandafter{\the\end@figuretoks\@@figure[p]}%
\global\end@figuretoks=\expandafter{\the\expandafter\end@figuretoks\BODY\@@endfigure}%
}
\NewEnviron{table}[1][htp]{%
\@@table[#1]\BODY\@@endtable
\global\end@tabletoks=\expandafter{\the\end@tabletoks\@@table[p]}%
\global\end@tabletoks=\expandafter{\the\expandafter\end@tabletoks\BODY\@@endtable}%
}
\newcounter{Endfigure}
\AtEndDocument{\clearpage\let\c@figure\c@Endfigure\the\end@figuretoks}
\newcounter{Endtable}
\AtEndDocument{\clearpage\let\c@table\c@Endtable\the\end@tabletoks}
\makeatother
\usepackage{lipsum}
\begin{document}
\lipsum
\begin{figure}
\centering
\includegraphics{example-image-a}
\caption{def}
\end{figure}
\lipsum
\begin{figure}
\centering
\includegraphics{example-image-b}
\caption{def}
\end{figure}
\lipsum
\begin{figure}
\centering
\includegraphics{example-image-c}
\caption{def}
\end{figure}
\lipsum
\begin{table}
\centering
\begin{tabular}
{ | c | c | c | }
\hline
Column 1 & Column 2 & Column 3 \\
\hline
Row 1 & Row 1 & Row 1 \\
Row 2 & Row 2 & Row 2 \\
Row 3 & Row 3 & Row 3 \\
\hline
\end{tabular}
\caption{table1}
\end{table}
\lipsum
\begin{table}
\centering
\begin{tabular}
{ | c | c | c | }
\hline
Column 1 & Column 2 & Column 3 \\
\hline
Row 1 & Row 1 & Row 1 \\
Row 2 & Row 2 & Row 2 \\
Row 3 & Row 3 & Row 3 \\
\hline
\end{tabular}
\caption{table2}
\end{table}
\end{document}
BTW...如非必要,不要修改模板。除非你是模板作者...那也不应该问出这样子的问题,应该自行提取MWE再提问...
考古...
好像用0.5\textwidth
代替9cm
可以解决,但是是什么原理?
正如群主所说,是因为两个minipage
的总间距超过了页面版心的宽度。
这段距离没有超过了两个minipage
的总宽度(18cm
)...
这同时导致一个警告:
Overfull \hbox (13.88782pt too wide) in paragraph at lines 8--18
[]$[]$ $[]$
一种解决办法是,将距离缩短为(比如8.5cm
),并再用\hfill
填充距离:
\documentclass{article}
\usepackage{graphicx}
\usepackage[showframe]{geometry}
\usepackage[type=upperleft]{fgruler}
\geometry{margin=2cm}
\begin{document}
\begin{figure}[htbp]
\begin{minipage}{8.5cm}
\centering
\includegraphics[width=8cm]{example-image-a}
\caption{1}
\end{minipage}\hfill%
\begin{minipage}{8.5cm}
\centering
\includegraphics[width=8cm]{example-image-b}
\caption{2}
\end{minipage}
\end{figure}
\end{document}
另一种解决办法是你所说的.5\textwidth
:
\documentclass{article}
\usepackage{graphicx}
\usepackage[showframe]{geometry}
\usepackage[type=upperleft]{fgruler}
\geometry{margin=2cm}
\begin{document}
\begin{figure}[htbp]
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=8cm]{example-image-a}
\caption{1}
\end{minipage}
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=8cm]{example-image-b}
\caption{2}
\end{minipage}
\end{figure}
\end{document}
会得到如下的结果:
但此时还是有警告(但这时的距离明显缩短了,仅有2.2222pt
):
Overfull \hbox (2.2222pt too wide) in paragraph at lines 8--18
[]$[]$ $[]$
如果你说你的眼睛就是尺,你还会发现其实还是没有exactly对齐,这是因为缺少%
吞去行末空格导致的。详见这个经典回答:
需要在两个minipage
之间加上一个%
:
\documentclass{article}
\usepackage{graphicx}
\usepackage[showframe]{geometry}
\usepackage[type=upperleft]{fgruler}
\geometry{margin=2cm}
\begin{document}
\begin{figure}[htbp]
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=8cm]{example-image-a}
\caption{1}
\end{minipage}%%%%注意这里的行末%不可或缺
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=8cm]{example-image-b}
\caption{2}
\end{minipage}
\end{figure}
\end{document}
@u134168 请你具体提供你的TeXLive
版本信息。您可以在cmd
输入tex -v
查看版本。
另外,AFAIK,xkeyval
以及过时了...
接近四年过去了啊...
首先修改一处小问题:
\lhead{\small{绝密 $\bigstar$ 启用前}}
\cfoot{数学试题第 \thepage 页(共 \pageref{LastPage}页)}
在\paageref{}
后加一个空格...
\lhead{\small{绝密 $\bigstar$ 启用前}}
\cfoot{数学试题第 \thepage 页(共 \pageref{LastPage} 页)}
页码显示异常, 有些页面有页码,有些页面没有页码
具体的说是,第3页和第6页页码消失
% \thispagestyle{empty} %%%注释
\noindent\textbf{第二部分\ \ 填空题:本部分共4道小题,每个小题~5 分, 共~ 20 分}
\begin{enumerate}\setcounter{enumi}{12}
%\item 设~$z = u^2\ln v$ , 而~$u= \dfrac{x}{y}, v = x-y$ , 则~$\dfrac{\partial z}{\partial x}= $~\underline{~~$\dfrac{2x}{y^2}\ln(x-y)+\dfrac{x^2}{y^2(x-y)}$~~}.
% \thispagestyle{empty} %%%注释
% \thispagestyle{empty} %%%注释
\noindent\textbf{(二)\ \ 选考题:共12分,请考生在第$22\sim23$中任选一道题作答,如果考生多做,则按给出解答的第一题计分.}
\vspace{0cm}
若如此做,可以得到:
PS.您这个模板拼接感很重,切忌到处搜罗代码粘贴进去。
首先,你的GEEexam.sty
已经和零蛋大的官方.sty
不一致,属于你的私有模板。而且把哪些部分放到你所说的\endinput
之前,也是令人很费解的...
其次,你在本页面提供的GEEexam.sty
文件在\endinput
之后还加了很多命令,input
都结束了你为什么还要加这些命令?是哪里学到的???
我猜你的意思是说,把下面这部分命令:
%以下自定义命令已经粘贴在宏包GEEexam的最后,如果此处删除以下命令,则运行出错
%==============================自定义命令=======================================================
%====填空题横线
\ExplSyntaxOn
\NewDocumentCommand \sh{g}
{\IfNoValueTF {#1}{\,\underline{\hbox to 0.8cm{}}\,}{\,\underline{\hbox to 0.8cm{\hfill#1\hfill}}\,}}%-------更短横线
\ExplSyntaxOff
\ExplSyntaxOn
\NewDocumentCommand \hh{g}
{\IfNoValueTF {#1}{\,\underline{\hbox to 1cm{}}\,}{\nolinebreak\textcolor[rgb]{1.00,0.00,0.00}{【#1】}}}%-------短横线
\ExplSyntaxOff
\ExplSyntaxOn
\NewDocumentCommand \hhh{g}
{\IfNoValueTF {#1}{\,\underline{\hbox to 2.5cm{}}\,}{\nolinebreak\hfill\textcolor[rgb]{1.00,0.00,0.00}{【#1】}}}
\ExplSyntaxOff
% 用法:\hhh输出_______ ;\hhh{增}输出______增_______;\hhh{\raisebox{.8ex}{$[\frac{\pi}{12},\frac{5\pi}{12}]$}}
\ExplSyntaxOn
\NewDocumentCommand \hhhh{g}
{\IfNoValueTF {#1}{\,\underline{\hbox to 5cm{}}\,}{\nolinebreak\hfill\textcolor[rgb]{1.00,0.00,0.00}{【#1】}}}%-------加长横线
\ExplSyntaxOff
%====阿拉伯数字转罗马数字\rmnum{ }\Rmnum{ }
\makeatletter
\newcommand{\rmnum}[1]{\romannumeral #1}
\newcommand{\Rmnum}[1]{\expandafter\@slowromancap\romannumeral #1@}
\makeatother
%====带圈数字2 \circnum{1} 项目编号:[\label=\circnum{\arabic*}]
\newcommand{\circled}[2][]{\tikz[baseline=(char.base)]
{\node[shape = circle, draw, inner sep = -1pt]%圈大小
(char) {\phantom{\ifblank{#1}{#2}{#1}}};%
\node at (char.center) {\makebox[0pt][c]{#2}};}}
\robustify{\circled}
\newcommand{\circnum}[1]{\circled[00]{\footnotesize#1}}%数大小
%====正体数学符号
\newcommand{\R}{\mathrm{\mathbf{R}}}
\newcommand{\N}{\mathrm{\mathbf{N}}}
\newcommand{\Q}{\mathrm{\mathbf{Q}}}
\newcommand{\Z}{\mathrm{\mathbf{Z}}}
\newcommand{\dt}{\,\symup{d} t}
\newcommand{\dx}{\,\symup{d} x}
\newcommand{\dy}{\,\symup{d} y}
%====圆弧\wideparen{ }
\DeclareSymbolFont{ugmL}{OMX}{mdugm}{m}{n}
\SetSymbolFont{ugmL}{bold}{OMX}{mdugm}{b}{n}
\DeclareMathAccent{\wideparen}{\mathord}{ugmL}{"F3}
%====平行四边形\parallelogram
\newcommand*\parallelogram{%
\mathord{\text{%
\tikz[baseline]
\draw (0,.1ex) -- (.8em,.1ex) -- (1em,1.4ex) -- (.2em,1.4ex) -- cycle;}}}
%====平行且相等\paralleleq
\usepackage{pict2e}
\newcommand\paralleleq{%
\begingroup
\setlength\unitlength{0.1em}%
\linethickness{0.5\unitlength}%
\roundcap
\mathrel{\begin{picture}(6,7)
\Line(0,-1)(6,-1)
\Line(0,0.5)(6,0.5)
\Line(1.5,1.5)(3.5,7)
\Line(3.5,1.5)(5.5,7)
\end{picture}}
\endgroup}
%====全等\congruent
\newcommand*\congruent{%
\mathrel{\text{%
\tikz \draw[baseline] (-.22em,-.4ex) arc (-90:-285:0.4ex) (-.22em,-.4ex) .. controls (0,-.4ex) and (0,.4ex) .. (.22em,.4ex) arc (90:-105:0.4ex) (-.4em,-.75ex) -- (.4em,-.75ex) (-.4em,-1.1ex) -- (.4em,-1.1ex);%
}}}
%====绝对值\abs{ }
\newcommand{\envert}[1]{\left\lvert#1\right\rvert}
\let\abs=\envert
%====列举法表示集合\set
\newcommand\set[1]{\left\{\rule{0cm}{1.7ex} {#1} \right\}}
%====描述法表示集合\Set
\newcommand\Set[2]{\left\{\rule{0cm}{1.7ex}\, {#1} \, \middle\vert \, {#2} \,\right\}}
%=====================================自定义命令结束========================================================
放在main.tex
就可行,放在GEEexam.cls
内就会报错...
编译你的.sty
和删除你所谓“自定义命令”遇到的第一个问题是:
Undefined control sequence.
\@currentHref ->page.\theHpage
我猜这与这个问题有关。
经过测试验证,将
\fancyfoot[C]{\kaishu{}理科数学试题\quad 第\thepage 页 \refstepcounter{page}\quad (共~\pageref{LastPage}~页)\hspace*{13cm} 理科数学试题\quad 第\thepage 页 \quad (共~\pageref{LastPage}~页)}
还原为
\fancyfoot[C]{\kaishu{}理科数学试题\quad 第\refstepcounter{fox}\thefoo\refstepcounter{foo}页 \quad (共~\ref{LastFox}~页)\hspace*{13cm} 理科数学试题\quad 第\refstepcounter{fox}\thefoo\refstepcounter{foo}页 \quad (共~\ref{LastFox}~页)}
这一关于唯一计数器名称的报错即消失。
我不确定是不是鱼老师修改可能有问题,但还有一个更简单修复办法,在GEEexam.sty
官方版本中,有如下被注释的代码:
% Line 22~26
%% =====页眉页脚设置===========================================
%\def\lastfox@putlabel{%
% \immediate\write\@auxout{%
% \string\newlabel{LastFox}{{\@arabic\c@foo}{}{}{}{}}}}
%\AtEndDocument{\lastfox@putlabel}
只要同时取消这一段注释,并且使用原来的页码引用方式:
\fancyfoot[C]{\kaishu{}理科数学试题\quad 第\refstepcounter{fox}\thefoo\refstepcounter{foo}页 \quad (共~\ref{LastFox}~页)\hspace*{13cm} 理科数学试题\quad 第\refstepcounter{fox}\thefoo\refstepcounter{foo}页 \quad (共~\ref{LastFox}~页)}
若如此做,则一切正常。
GEEexam.sty
\ProvidesPackage{GEEexam}[2017/09/27 v1.0 Non-standard LaTeX package]
%% =====添加一些数学环境的宏包==================================
\RequirePackage{amsmath,amssymb}%
\def\dif{\mathop{}\!\mathrm{d}}
\DeclareMathOperator{\rank}{rank}
\RequirePackage{bm}
\RequirePackage{pifont}
\RequirePackage{extarrows} %长等号
\RequirePackage{scalerel}%缩放公式大小
\RequirePackage{array}%m{3em}
\usepackage{tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
%% ===========================================================
%% =====设置A3试卷纸张的页边距==================================
\RequirePackage{geometry,calc}
\geometry{a3paper,twocolumn,landscape,hmargin={3.5cm,1.3cm},
vmargin={1.5cm,1.5cm},footskip=0.75cm,headsep=0.25cm}
%% ===========================================================
%% =====页眉页脚设置===========================================
\def\lastfox@putlabel{%
\immediate\write\@auxout{%
\string\newlabel{LastFox}{{\@arabic\c@foo}{}{}{}{}}}}
\AtEndDocument{\lastfox@putlabel}
\newcounter{foo}
\newcounter{fox}
\addtocounter{foo}{1}
\RequirePackage{tikz}
\RequirePackage{lastpage}
\newcommand{\defen}[2][1cm]{\hspace*{\fill}\raisebox{-1.1ex}{\tikz\draw[line width=1pt,dash pattern=on 1pt off 2.5pt on 1pt off 2.5pt] (0pt,0pt)--(#1 ,0pt)node[right=-1mm]{(#2~分)};}\newline}
\RequirePackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\setlength{\columnseprule}{0.4pt}
\setlength{\columnsep}{1.8cm}
\fancyfoot[C]{\kaishu{}理科数学试题\quad 第\refstepcounter{fox}\thefoo\refstepcounter{foo}页 \quad (共~\ref{LastFox}~页)\hspace*{13cm} 理科数学试题\quad 第\refstepcounter{fox}\thefoo\refstepcounter{foo}页 \quad (共~\ref{LastFox}~页)}
% \fancyfoot[C]{\kaishu{}理科数学试题\quad 第\thepage 页 \refstepcounter{page}\quad (共~\pageref{LastPage}~页)\hspace*{13cm} 理科数学试题\quad 第\thepage 页 \quad (共~\pageref{LastPage}~页)}
\renewcommand{\headrulewidth}{0pt}
%% ===========================================================
%% =====页眉【绝密*启用前】================================
\RequirePackage{color,xcolor}
\RequirePackage{enumitem}
\def\juemi{\noindent{\heiti\zihao{-4} 绝密$\bigstar$启用前}}
\def\biaoti#1{\begin{center}{\zihao{3} #1}\end{center}}
\def\fubiaoti#1{\begin{center}{\zihao{2}\heiti #1}\end{center}}
%% ===========================================================
%% =====设置数学字体为新罗马字体================================
\RequirePackage[T1]{fontenc}
\RequirePackage{mathptmx}
\newfontfamily\TNRBI{Times New Roman Bold Italic}
\newcommand{\bfit}[1]{\text{\TNRBI #1}}
%% ===========================================================
%% =====设置大题标题格式=======================================
\ctexset{section = {name = {,、\hspace*{-5mm}},
number = \chinese{section},
format = {\zihao{5}\heiti\raggedright}}}
\ctexset{subsection = {name = {\hspace{5mm},\hspace*{-1mm}},
number = (\chinese{subsection}),
format = {\zihao{5}\heiti\raggedright}}}
\RequirePackage{titlesec}
\titlespacing*{\section}{0pt}{9pt}{4pt}
%% =====选择题选项格式设置====================================
\usepackage{tasks}%选择题宏包,tasks环境
% \settasks{counter-format={tsk[A].},
% label-offset={0.4em},
% label-align=left,
% column-sep={2pt},
% item-indent={1pt},
% before-skip={-0.7em},
% after-skip={-0.7em}}
% \usepackage{tasks}%选择题宏包,tasks环境
% texlive 2021 用以下设置
%=====================================
\settasks{ %
label=\Alph*., %
label-offset={0.4em}, %
label-align=left, %
column-sep={10pt}, %
label-width=2ex, %
item-indent={40pt}, %
before-skip={-0.7em}, %
after-skip={-0.7em} %
} %
%=====================================
% 选择题示例
%\begin{tasks}(4)
% \task
% \task
% \task
% \task
%\end{tasks}
%------------------------------ 选择题 ----------------------------------%
%\setcounter{enumi}{12}
\def\tiankongdaan#1{\makebox[3em][c]{#1}}
\newcommand{\blank}[1]{\underline{\tiankongdaan{\qquad~}}}
\DeclareOption{ans}{\renewcommand{\blank}[1]{\,\underline{#1}\,
}}
\ProcessOptions
%------------------------------ 填空题 ----------------------------------%
\ExplSyntaxOn
\NewDocumentCommand \sh{g}
{\IfNoValueTF {#1}{\,\underline{\hbox to 0.8cm{}}\,}{\,\underline{\hbox to 0.8cm{\hfill#1\hfill}}\,}}%-------加短横线
\ExplSyntaxOff
\ExplSyntaxOn
\NewDocumentCommand \hh{g}
{\IfNoValueTF {#1}{\,\underline{\hbox to 1cm{}}\,}{\nolinebreak\textcolor[rgb]{1.00,0.00,0.00}{【#1】}}}%-------短横线
\ExplSyntaxOff
\ExplSyntaxOn
\NewDocumentCommand \hhh{g}
{\IfNoValueTF {#1}{\,\underline{\hbox to 2.5cm{}}\,}{\nolinebreak\hfill\textcolor[rgb]{1.00,0.00,0.00}{【#1】}}}
\ExplSyntaxOff
% 用法:\hhh输出_______ ;\hhh{增}输出______增_______;\hhh{\raisebox{.8ex}{$[\frac{\pi}{12},\frac{5\pi}{12}]$}}
\ExplSyntaxOn
\NewDocumentCommand \hhhh{g}
{\IfNoValueTF {#1}{\,\underline{\hbox to 5cm{}}\,}{\nolinebreak\hfill\textcolor[rgb]{1.00,0.00,0.00}{【#1】}}}%-------加长横线
\ExplSyntaxOff
%% =====自定义数学命令=========================================
% 阿拉伯数字转罗马数字\rmnum{ }\Rmnum{ }
\makeatletter
\newcommand{\rmnum}[1]{\romannumeral #1}
\newcommand{\Rmnum}[1]{\expandafter\@slowromancap\romannumeral #1@}
\makeatother
% 带圈数字2 \circnum{1} 项目编号:[\label=\circnum{\arabic*}]
\newcommand{\circled}[2][]{\tikz[baseline=(char.base)]
{\node[shape = circle, draw, inner sep = -1pt]%圈大小
(char) {\phantom{\ifblank{#1}{#2}{#1}}};%
\node at (char.center) {\makebox[0pt][c]{#2}};}}
\robustify{\circled}
\newcommand{\circnum}[1]{\circled[00]{\footnotesize#1}}%数大小
% 正体数学符号
\newcommand{\R}{\mathrm{\mathbf{R}}}
\newcommand{\N}{\mathrm{\mathbf{N}}}
\newcommand{\Q}{\mathrm{\mathbf{Q}}}
\newcommand{\Z}{\mathrm{\mathbf{Z}}}
\newcommand{\dt}{\,\symup{d} t}
\newcommand{\dx}{\,\symup{d} x}
\newcommand{\dy}{\,\symup{d} y}
%圆弧\wideparen{ }
\DeclareSymbolFont{ugmL}{OMX}{mdugm}{m}{n}
\SetSymbolFont{ugmL}{bold}{OMX}{mdugm}{b}{n}
\DeclareMathAccent{\wideparen}{\mathord}{ugmL}{"F3}
%平行四边形\parallelogram
\newcommand*\parallelogram{%
\mathord{\text{%
\tikz[baseline]
\draw (0,.1ex) -- (.8em,.1ex) -- (1em,1.4ex) -- (.2em,1.4ex) -- cycle;}}}
%平行且相等\paralleleq
\usepackage{pict2e}
\newcommand\paralleleq{%
\begingroup
\setlength\unitlength{0.1em}%
\linethickness{0.5\unitlength}%
\roundcap
\mathrel{\begin{picture}(6,7)
\Line(0,-1)(6,-1)
\Line(0,0.5)(6,0.5)
\Line(1.5,1.5)(3.5,7)
\Line(3.5,1.5)(5.5,7)
\end{picture}}
\endgroup}
%全等\congruent
\newcommand*\congruent{%
\mathrel{\text{%
\tikz \draw[baseline] (-.22em,-.4ex) arc (-90:-285:0.4ex) (-.22em,-.4ex) .. controls (0,-.4ex) and (0,.4ex) .. (.22em,.4ex) arc (90:-105:0.4ex) (-.4em,-.75ex) -- (.4em,-.75ex) (-.4em,-1.1ex) -- (.4em,-1.1ex);%
}}}
%绝对值\abs{ }
\newcommand{\envert}[1]{\left\lvert#1\right\rvert}
\let\abs=\envert
%列举法表示集合\set
\newcommand\set[1]{\left\{\rule{0cm}{1.7ex} {#1} \right\}}
%描述法表示集合\Set
\newcommand\Set[2]{\left\{\rule{0cm}{1.7ex}\, {#1} \, \middle\vert \, {#2} \,\right\}}
\endinput%%%放最后
mwe.tex
\documentclass[11pt,space]{ctexart}
\usepackage{GEEexam}
\usepackage{zhlipsum}
\begin{document}
填空题横线\hhh
阿拉伯数字转罗马数字~$\Rmnum{3}$
带圈数字~$\circnum{1}$
正体符号~$\R$
圆弧~$\wideparen{AB}$
平行四边形~$\parallelogram$
平行且相等~$\paralleleq$
全等~$\congruent$
绝对值~$\abs{x}$
列举法~$\set{1,2,3}$
描述法~$\Set{x}{1<x<2}$
\zhlipsum[1-10]
\end{document}
你问的是对齐。
那你的排版化学式的基本代码(也许是对不齐的情况)为什么不给出?
不给测试代码谁能知道你要对齐的是什么东西。
请“补充问题”😖
chemfig
如何排版。如果下面的化学式排版有瑕疵,与本问题无关,请自行参照chemfig
的文档或者开新的问题;chemfig
实现,一个可能的例子如下:\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum}
\usepackage{chemfig}
\usepackage[version=4]{mhchem}
\begin{document}
\lipsum[2]
\begin{enumerate}[label=(\arabic*),start=9]
\item \parbox{\linewidth}{\schemestart
\chemfig{[:-30]CH_2=CH-CH_2-CH_3}
\arrow{->[\ce{KMnO4, H2O, \Delta}][\ce{H3O+}]}
\schemestop}
\item \parbox{\linewidth}{\schemestart
\chemfig{*6(-=-=(-CH=CH_2)-=-=)}
\arrow{->[\ce{O3}]}
\chemfig{*6(-=-=(-CHO)-=-=)}
\arrow{->[\ce{Zn, H2O}]}
\chemfig{*6(-=-=(-CH_2OH)-=-=)}
\schemestop}
\item \parbox{\linewidth}{\schemestart
\chemfig{*6(-=-=(-CH_2-CH(CH_3)-OH)-=-=)}
\arrow{->[\ce{HF}]}
\chemfig{*6(-=-=(-CH_2-CH(CH_3)-F)-=-=)}
\schemestop}
\end{enumerate}
\lipsum[2]
\end{document}
\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum}
\usepackage{graphicx}
\begin{document}
\lipsum[2]
\begin{enumerate}[label=(\arabic*),start=9]
\item \parbox{\linewidth}{\includegraphics[width=3cm]{example-image-a}}
\item \parbox{\linewidth}{\includegraphics[width=4cm]{example-image-b}}
\item \parbox{\linewidth}{\includegraphics[width=5cm]{example-image-c}}
\end{enumerate}
\lipsum[2]
\end{document}
尝试想在自己的文件中设置题干在左,图片在右的样式
“图文排版”可以使用wrapfig
,wrapfig2
以及wrapstuff
宏包等方式实现。
除此之外,在exam-zh-doc
中也提到了text-figure
宏包:
在使用宏包之前必须看文档(问AI你根本无法系统的学习到知识),这意味着你要在终端分别执行:
texdoc wrapfig
texdoc wrapfig2
texdoc wrapstuff
这里只给出一个基于wrapstuff
的例子(请必须看着wrapstuff
的文档来写代码做尝试,而不是无脑问AI最后报错不知所措,或者陷入和AI的扯皮):
\documentclass{ctexart}
\usepackage[a4paper,top=1.5cm,bottom=1.5cm]{geometry}
\usepackage{zhlipsum}
\usepackage{wrapstuff}
\usepackage{graphicx}
\begin{document}
\zhlipsum[2]
\begin{wrapstuff}[r]
\includegraphics[width=6cm,height=10cm]{example-image}
\end{wrapstuff}
\zhlipsum[1]\wrapstuffclear
\zhlipsum[2]
\end{document}
至于paracol
,你为什么会如此轻信AI的做法,texdoc paracol
可以看到,这实际上是用来分栏用的:
我个人不觉得这是用来实现图文环排的最好办法...
回到你的MWE,所谓“请 AI 帮忙给一个标准的示例”:
ctex
宏包(?)caption-of
是Undefined control sequence.
这意味着你需要调用caption
或者capt-of
宏包补上之后,你的AI实际上给了你“基础版”和“进阶版”,理应分别测试:
\documentclass{ctexart}
\usepackage{paracol} % 分栏核心包
\usepackage{graphicx} % 图片支持
\usepackage{lipsum} % 生成示例文本(实际使用时删除)
\usepackage{capt-of}
\begin{document}
% ========== 基础版(自动等宽分栏)==========
\begin{paracol}{2} % 数字2表示分两栏
% 左栏(文字部分)
\begin{leftcolumn}
\section{文字标题}
\lipsum[1][1-4] % 示例文本(替换为实际内容)
\begin{itemize}
\item 项目列表示例1
\item 项目列表示例2
\item 数学公式示例:$E=mc^2$
\end{itemize}
\end{leftcolumn}
% 右栏(图片部分)
\begin{rightcolumn}
\includegraphics[width=\linewidth]{example-image-a} % 使用实际图片路径
\captionof{figure}{图片说明文字} % 需要 \usepackage{caption}
\end{rightcolumn}
\end{paracol}
\end{document}
没什么问题。
\documentclass{ctexart}
\usepackage{paracol} % 分栏核心包
\usepackage{graphicx} % 图片支持
\usepackage{lipsum} % 生成示例文本(实际使用时删除)
\usepackage{capt-of}
\begin{document}
% ========== 进阶版(自定义栏宽+间距)==========
\begin{paracol}[
columnwidths={0.6\linewidth 0.4\linewidth}, % 左栏60%,右栏40%
gutter=0.02\linewidth, % 栏间距2%
rulebetween % 显示分栏线(可选)
]{2}
\begin{leftcolumn}
\section{自定义宽度标题}
\lipsum[2][1-3]
\end{leftcolumn}
\begin{rightcolumn}
\includegraphics[width=\linewidth, height=5cm]{example-image-b} % 固定高度
\captionof{figure}{自定义宽度布局示例}
\end{rightcolumn}
\end{document}
确实出现如下报错:
Missing number, treated as zero.
<to be read again>
这说明你使用\begin{paracol}[xxxx]{2}
的语法(syntax)有问题...
If a \begin{paracol}
has the optional numleft argument to specify the number of leading columns nl together with the total n given by num, columns in the environment are laid out across two adjacent pages.
\begin{paracol}
的第一个可选参数为[<numleft>]
,指的是前导列的数量,需要的是一个数,你的AI放进去的是columnwidths={0.6\linewidth 0.4\linewidth},gutter=0.02\linewidth,rulebetween
,在文档中根本找不到名为gutter
和rulebetween
的key...
你完全陷入AI的幻觉了,要想用好AI,就不能轻信AI。如果你没有自己对问题的判断力,那你就根本不应该使用AI。
如果你需要调整比例,也许可以看一下文档的7.3节,提供了\columnratio
的命令....
回到要实现左文右图的排版上来,我个人觉得这些宏包的实践是要优于paracol
的:wrapfig
,wrapfig2
以及wrapstuff
。要想学好LaTeX
,务必学会看文档,轻信AI只会变成AI的奴隶,并且失去自己的核心竞争力。
wrapfig
,wrapfig2
以及夏老师的text-figure
宏包的使用方法(看文档而不是用AI,比如夏老师的私有宏包text-figure
根本没有上传CTAN,AI会的概率微乎其微),自己给出例子。以上。
可以试试这组参数
xleftmargin=.35em,%
xrightmargin=.35em,%
geometry
宏包不修改左右页面相对距离以及指定文档类的oneside
选项的前提下的(如果修改了,这组参数也要做相应修改):\documentclass[oneside]{ctexbook}
\usepackage{zhlipsum}
\usepackage[showframe]{geometry}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{titlesec}
\titleformat*{\section}{\makebox[\textwidth][c]}
\titleformat{\section}[frame]
{\color{magenta}}
{\centering\footnotesize\enspace 节 \thesection\enspace}
{8pt}
{\bfseries\filcenter\songti}
[\vspace{-10pt}]
\usepackage{listings}
\usepackage{xcolor}
\lstdefinelanguage{VBA}{
morekeywords={Sub, End, Dim, As, Set, Range, Worksheet, MsgBox, If, Then, Else, For, Next, Do, While, Loop, Integer, String},
sensitive=true,
morecomment=[l]{'},
morestring=[b]{"},
keywordstyle=\color[HTML]{0184bc},
stringstyle=\color[HTML]{41a977},
basicstyle=\small\ttfamily,
keepspaces=true,
numbers=left,
columns=fullflexible,
xleftmargin=.35em,%
xrightmargin=.35em,%
}
\lstset{
language=VBA,
frame=single,
linewidth=\dimexpr\textwidth\relax,
escapeinside=``
}
\begin{document}
\section{初步}
\begin{lstlisting}[caption={生成斐波那契数列},label={code:fib}]
'To generate the Fib Sequence
Sub GenerateFibonacci()
\end{lstlisting}
\end{document}
你的代码这么长(足足有116行),你觉得他是最小工作示例吗?
Hello, World!
,缩短20行lisitngs
宏包无关,同时再把你有关\lstset
设置全删了,缩短50行\documentclass{ctexbook}
\usepackage{geometry}
\ctexset{
chapter = {
name = {\S}, % 将"第X章"改为"§ X"
number = \arabic{chapter}, % 阿拉伯数字编号
format = \songti\large\bfseries\centering, % 标题格式
beforeskip = 2.5ex, % 标题前间距
afterskip = 2.5ex, % 标题后间距
}
}
\begin{document}
\chapter{哈哈哈}
\section{初步}
Hello, World!
\end{document}
\ctexset
内不能有空行...LaTeX
不是python,不能想空行就空行,每一个空格,每一个~
甚至注释符号%
都有其作用,必须每一步都谨小慎微。
希望下次不要再看到100+行的最大工作示例。
\chapter{哈哈哈}
Not allowed in LR mode.
\renewcommand{\contentsname}{%
\begin{center}
\normalfont\songti\bfseries 文章目录
\end{center}
}
这又是为什么呢?原因就是Not allowed in LR mode.
....
附第二份MWE:
\documentclass{ctexbook}
\usepackage{zhlipsum}
\usepackage{titletoc}
\usepackage{titlesec}
\usepackage{geometry}
\usepackage{fontspec}
\geometry{a4paper,centering,scale=0.9}
\renewcommand{\contentsname}{%
\begin{center}
\normalfont\songti\bfseries 文章目录
\end{center}
}
\begin{document}
\tableofcontents
\chapter{哈哈哈}
\section{初步}
\end{document}
LaTeX
技能,甚至来个小学生不断二分编译都能提取出来....只是因为大家的代码太长....都懒....这些都是哪里学的....请使用@u79794 老师提供的方法....
你显然应该每加一个设置就编译,如果报错找问题,没报错再进行下一个配置。你一开始面临的代码存在多处问题,这些问题互相影响,让你的代码很难debug....
这种形如方程x+y=const的映射必定是线性的,所以找到一个用两重循环的变量\x
以及\y
正好可以覆盖所需位置的线性坐标映射即可:
\documentclass[border=2pt,tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \x in {1,2}
\foreach \y in {1,...,6}
\node at (\x-.5,\y-.5) [scale=.75] {$(\x,\y)$};
\draw (0,0) grid ([xshift=-.01pt]2,6);
\clip [xshift={2cm-.01pt}] (0,0) -- (45:{3*sqrt(2)}) -- (90:6) -- cycle;
\draw [xshift=2cm,rotate=45,step={sqrt(2)/2}] (0,0) grid (6,6);
\foreach \x in {5,...,9}
\foreach \y in {1,...,\fpeval{(10-\x)}}
\node at (\x/2,\fpeval{\y+(\x-5)/2}) [scale=.5] {$(\fpeval{\x/2},\fpeval{\y+(\x-5)/2})$};
\end{tikzpicture}
\end{document}
其实也就是小学生找规律问题的\pgffor
版本罢了...
General Case:
\documentclass[border=2pt,tikz]{standalone}
\newcommand*{\drawmygrid}[2]{%
\begin{tikzpicture}
\foreach \x in {1,...,#1}
\foreach \y in {1,...,#2}
\node at (\x-.5,\y-.5) [scale=.75] {$(\x,\y)$};
\draw (0,0) grid ([xshift=-.01pt]#1,#2);
\clip [xshift={#1cm-.01pt}] (0,0) -- (45:{(#2/2)*sqrt(2)}) -- (90:#2) -- cycle;
\draw [xshift={#1cm},rotate=45,step={sqrt(2)/2}] (0,0) grid (#2,#2);
\def\Na{\fpeval{2*#1+1}}
\def\Nb{\fpeval{\Na+#2-1}}
\foreach \x in {\Na,...,\fpeval{\Nb-1}}
\foreach \y in {1,...,\fpeval{\Nb-\x}}
\node at (\x/2,\fpeval{\y+(\x-\Na)/2}) [scale=.5] {$(\fpeval{\x/2},\fpeval{\y+(\x-\Na)/2})$};
\end{tikzpicture}
}
\begin{document}
\drawmygrid{2}{6}
\drawmygrid{5}{10}
\drawmygrid{8}{15}
\end{document}
我似乎觉得这个问题还和字体有关:
这个链接里面的不同字体,破折号的长度并不总是2\ccwd
,也并不总不是2\ccwd
,此外如果直接用\rule
,似乎是可以同时控制高度,长度和粗细的...
也许可以在ctex-kit
的issues里面搜索,有不少有关的讨论。
\documentclass[fontset=ubuntu]{ctexart}
\begin{document}
我能吞下玻璃而不伤身体.
你好-远方不远.
你好--远方不远.
你好---远方不远.
你好——远方不远.
你好\rule[.6ex]{2\ccwd}{.5pt}远方不远.
我能吞下玻璃而不伤身体.
\end{document}
xeCJK
中也有一些黑魔法,与标点距离有关的还有这个回答:
\documentclass[fontset=ubuntu]{ctexart}
\xeCJKsetwidth{——}{1.2\ccwd}
\begin{document}
我能吞下玻璃而不伤身体.
你好——远方不远.
你好\rule[.6ex]{2\ccwd}{.5pt}远方不远.
我能吞下玻璃而不伤身体.
\end{document}
CTeX
套装的编译原理,基于cct或者直接显式调用CJK
宏包的中文处理方式从目前来看已经过时了。如果没有中文数学期刊/某些古早模板的投稿/编译需求,请使用新的发行版TeXLive
或者MikTeX
,并且使用ctex
宏包而不是CJK
宏包自带的CJK
环境,OP提供的这一网上经典的mp图片似乎有些过时:
这里暂时没有直接回答你的问题,但我探索了一个可行的方案(也应该是比较现代的方案),可以使用luamplib
包直接导出为.pdf
注意此时文件应该保存为test.tex
而不是test.mp
\documentclass[border=5mm]{standalone}
\usepackage{ctex}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
% 坐标轴绘制
drawarrow origin -- (0,100); % Y轴(向上)
drawarrow origin -- (100,0); % X轴(向右)
% 原点强化显示
drawdot origin withpen pencircle scaled 2pt;
% 中文标签系统
label.bot(btex 原点 etex, origin); % 原点标注
label.lft(btex $y$ etex, (0,100)); % Y轴标签
label.rt (btex $x$ etex, (100,0)); % X轴标签
endfig;
\end{mplibcode}
\end{document}
在TeXLive
下直接使用lualatex test.tex
编译可以得到图片。
问 如何设置章节标题以及节标题的行距?