MWE不规范,预期效果图也没有,甚至还要手动帮你调整代码,还要run
一下之后再理解你的"调整宽度和行高。内容居中"是什么意思,对回答者极不友好。
代码请用代码块包裹,你这个问题必须需要提供符合你排版的文章layout
要求的具体情况的代码才好调整具体样式和大小。
不然我在我的电脑画的表格和尺寸大小,放到你的所谓"模板"里面还是会很不好看,你还得接着提问。
提供一份基于tabularray
的解答
\documentclass[a4paper,landscape]{article}
\usepackage[margin=.5in]{geometry}
\usepackage{lipsum}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\begin{document}
\begin{tblr}{
vlines,cells={valign=m},
colspec = {*{2}{Q[2cm,c]}*{6}{Q[3cm,c]}},
row{1,2}={font=\bfseries\small},
column{1}={font=\bfseries\small},
abovesep=0pt, belowsep=2pt, rowsep=2pt,
}
\toprule
\SetCell[r=2]{m} Dataset & \SetCell[r=2]{m} Embedding Capacity (bits) & \SetCell[c=6]{m} Extraction Error (\%) \\
\midrule
& & Addition and Deletion of Punctuation Marks & Addition and Deletion of Stop Words & Synonym Replacement & Random Word Insertion & Character Deletion and Swapping & Word Order Reversal \\
\midrule
AG News & 30,000 & 0 & 0 & 0 & 0 & 2.92 & 0.26 \\
\midrule
Dbpedia & 90,000 & 0 & 0 & 0 & 1.27 & -- & -- \\
\bottomrule
\end{tblr}
\end{document}
MWE定义
一个不一定优雅的解决方式是:
\documentclass[10pt,a4paper]{ctexart}
\usepackage{enotez}
\setenotez{
list-name = {\small\noindent【注释】},
}
\ExplSyntaxOn
\cs_set:Npn \theendnote {【\zhnum{endnote}】}
\ExplSyntaxOff
\begin{document}
This is\endnote{With an endnote.} some text.\endnote{With two endnotes.}
\printendnotes
\end{document}
这是由于在enotez.sty
中如下定义了l3keys-coices
% Line 150
counter-format .choice: ,
counter-format / arabic .code:n = \cs_set:Npn \theendnote {\arabic{endnote}} ,
counter-format / alph .code:n = \cs_set:Npn \theendnote {\alph{endnote}} ,
counter-format / Alph .code:n = \cs_set:Npn \theendnote {\Alph{endnote}} ,
counter-format / roman .code:n = \cs_set:Npn \theendnote {\roman{endnote}} ,
counter-format / Roman .code:n = \cs_set:Npn \theendnote {\Roman{endnote}} ,
counter-format / symbols .code:n = \cs_set:Npn \theendnote {\fnsymbol{endnote}} ,
另外要注意\zhnumber
和\zhnum
区别,前者作用于数字,后者作用于计数器.
应该有更优雅(妥当)的修改方式, 无奈本人不善latex3
也不善仔细研究文档...
一个可能的答案是:
\documentclass{article}
\usepackage{amsmath,amssymb,mathrsfs}
\usepackage{nicematrix}
\usepackage{tikz}
\newcommand*{\BB}[1][]{\mathscr{B}^{#1}}
\begin{document}
\[
\begin{NiceMatrix}[create-medium-nodes]
\phantom{0} & \alpha_1 & \alpha_2 & \cdots & \alpha_t & \phantom{0} \\
\phantom{0} & \BB \alpha_1 & \BB \alpha_2 & \cdots & \BB \alpha_t & \phantom{0} \\
\phantom{0} & \BB[2] \alpha_1 & \BB[2] \alpha_2 & \cdots & \BB[2] \alpha_t &\phantom{0} \\
\phantom{0} & \vdots & \vdots & \ddots & \vdots &\phantom{0} \\
\phantom{0} & \BB[k_1-1] \alpha_1 & \BB[k_2-1] \alpha_2 & \cdots & \BB[k_n-1] \alpha_t &\phantom{0} \\
\phantom{0} & \BB[k_1] \alpha_1 & \BB[k_2] \alpha_2 & \cdots & \BB[k_n] \alpha_t & \phantom{0} \\
\CodeAfter
\tikz[name suffix=-medium]{
\draw[cyan,dashed] (1-2.north west) rectangle (5-5.south east);
\draw[magenta!60] (2-1.north west) rectangle (6-6.south east);
}
\end{NiceMatrix}
\]
\end{document}
-------------------------补充回答-------------------------
\documentclass{article}
\usepackage{amsmath,amssymb,mathrsfs}
\usepackage{nicematrix}
\usepackage{tikz}
\newcommand*{\BB}[1][]{\mathscr{B}^{#1}}
\begin{document}
\[
\begin{NiceMatrix}[create-medium-nodes]
\phantom{1} & \alpha_1 & \alpha_2 & \cdots & \alpha_t & \phantom{1} \\
\phantom{1} & \BB \alpha_1 & \BB \alpha_2 & \cdots & \BB \alpha_t & \phantom{1} \\
\phantom{1} & \BB[2] \alpha_1 & \BB[2] \alpha_2 & \cdots & \BB[2] \alpha_t &\phantom{1} \\
\phantom{1} & \vdots & \vdots & \ddots & \vdots &\phantom{1} \\
\phantom{1} & \BB[k_1-1] \alpha_1 & \BB[k_2-1] \alpha_2 & \cdots & \BB[k_n-1] \alpha_t &\phantom{1} \\
\phantom{1} & \BB[k_1] \alpha_1 & \BB[k_2] \alpha_2 & \cdots & \BB[k_n] \alpha_t & \phantom{1} & \alpha_{t+1} & \cdots & \alpha_s \\
\CodeAfter
\tikz[name suffix=-medium]{
\draw[cyan,dashed] (1-2.north west) rectangle (5-5.south east);
\draw[magenta!60] (2-1.north west) rectangle (6-6.south east);
}
\end{NiceMatrix}
\]
\end{document}
TikZ
的技巧性实在是太强了,我还有很长的路要走(落泪)
非常感谢外国网友的帮助,但我微调了一下,感觉下面的代码还是有些"不优雅"的问题(哎)
另外,请你查看围栏代码块语法,学会讲代码放到代码块里,以便他们正确的高亮。 (Un)Happy TikZing!
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[rotate=120,]% rotate=120
\foreach \i [
count=\j from -1, % trick to start from -1
evaluate=\i as \invi using int(11-\i),
evaluate=\j as \invj using int(11-\j),
] in {0,...,11} {
\node[
fill, circle,
inner sep=1pt, outer sep=3pt,
label={
[inner sep=0pt, minimum width=.5em,] % <angle:label-text>
{360/12*(\i-1/2)+120}:{\footnotesize $a_{1,\invi}$}
}
] (a\i) at ({360/12*(\i-1/2)}:2.5) {};
\ifnum\i=0\else
\draw[<-] (a\i) -- node[inner sep=0pt, circle, label={
[circle, inner sep=0pt]{360/12*(\i-1)+120}:{\footnotesize$\alpha_{1,\invj}$}
}] {} (a\j);
\fi
}
\draw[<-] (a0) -- node[
inner sep=0pt, circle,
label={
[circle, inner sep=0pt, swap]
{-360/12+120}:{\footnotesize$\alpha_{1,0}$}
}] {} (a11);
\end{tikzpicture}
\end{document}
为什么不提供最小工作示例?
告诉我,为什么!!!!
目测你是使用的行内公式的大小
% This document is compiled using xeLaTeX
\documentclass{ctexart}
\usepackage{amsmath,amssymb}
\pagestyle{empty}
\begin{document}
\[
\because 6+t =
\]
\[
\therefore \text{救生圈}
\]
\[
{\textstyle \because} 6+t =
\]
\[
{\textstyle \therefore} \text{救生圈}
\]
\[
{\scriptstyle \because} 6+t =
\]
\[
{\scriptstyle \therefore} \text{救生圈}
\]
\[
{\scriptscriptstyle \because} 6+t =
\]
\[
{\scriptscriptstyle \therefore} \text{救生圈}
\]
\end{document}
感谢@u79794 和 TSE上的beamer高手samcarter_is_at_topanswers.xyz
可以考虑使用picture
或者tikzpicture
环境来定位图片位置,如下代码
\documentclass{beamer}
\usetheme{AnnArbor}
\usepackage[12pt]{ctex}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\begin{frame}{Title}
contents ...
\end{frame}
% 设置当前 frame 的背景图片
\setbeamertemplate{background}{%
% \begin{picture}(200,250) % <- bad solution to adjust by yrself
% \includegraphics[width=\paperwidth,height=.3\paperheight]{example-image}
% \end{picture}
\begin{tikzpicture}[overlay, remember picture]
% maybe a better solution to position the image
\node[yshift=6em] at (current page.south) {\includegraphics[width=\paperwidth,height=.3\paperheight]{example-image}};
\end{tikzpicture}
}
\begin{frame}
\begin{center}
{\LARGE Thanks for your attention!}
\end{center}
\end{frame}
% 重置背景模板
\setbeamertemplate{background}{}
\begin{frame}
\begin{center}
{\LARGE Thanks for your attention!}
\end{center}
\end{frame}
\end{document}
这就是LaTeX
浮动体的特色,不要尝试去固定"浮动"的图片/表格的位置,在行文中避免使用上图
,下表
等方式来指代,而改用图3.1
,表1-2
的方式来指代。
同时,强烈不建议使用float
宏包的H
参数来实现,有可能出现出乎意料的排版结果。使用LaTeX
,就应该接纳他这种"浮动"的特色。在我看来,需要改变的应该是使用LaTeX
排版的你对图片/表格位置应该"固定"的看法。
另外,你的MWE代码不规范。请参照下图。
在lshort-zh-cn
中对文档结构有如下的说明:
你的MWE中,你想要编号的部分都被放置在了\frontmatter
之后而\mainmatter
之间,此时属于前言部分,不计入文章正文,因此会出现0.1
,0.3.1
的情况;
另外,你的MWE不规范,你使用了elegantbook
模板,因此必须在相同目录下放置elegantbook.cls
文件才行,而你提供的压缩包中仅有总笔记.tex
文件,这违背了MWE中在别人的电脑上直接编译即可复现你的问题的原则,另外你的鸽子.png
也并未提供,还需要复习一下MWE的定义,争取下次规范提问。
另,强烈建议在使用模板之前认真学习一下上面提到的lshort-zh-cn
文档,对于入门非常有帮助。
下面是MWE,只要更改\mainmatter
的位置即可:
\documentclass[lang=cn,newtx,10pt,scheme=chinese,titlestyle=hang]{elegantbook}
\title{大学期间笔记}
\author{cql}
\date{\today}
\version{1.0}
\extrainfo{别问为什么用英文,问就是锻炼自己}
% \cover{鸽子.jpg}
\definecolor{structurecolor}{RGB}{0,0,0}
\definecolor{main}{RGB}{70,70,70}
\definecolor{second}{RGB}{115,45,2}
\definecolor{third}{RGB}{0,80,80}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{extarrows}
\usepackage{stmaryrd}
\usepackage{tikz-cd}
\usetikzlibrary{cd}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{multicol} %导入multicols包
\usepackage{CJKfntef}
\usepackage{rotating} %用于旋转对象(旋转包)
\usepackage{color}
\usepackage{hyperref}
\usepackage{ctex}
\usepackage{hyperref}
\usepackage{comment}
\usepackage{array}
%\usepackage{tasks}
\usepackage{tikz}
\usetikzlibrary{positioning}
\setcounter{tocdepth}{3}
\usepackage{fancyhdr}
\begin{document}
\frontmatter
\maketitle
\mainmatter
\tableofcontents
\chapter{Analysis}
\section{Mathmatical Anlysis}
\subsection{Fundamental Theorem of Real Number System}
\subsection{Univariate differential calculus}
\subsubsection{Differentaable definition}
\section{Real Analysis}
\section{Complex Analysis}
\subsection{Basic properties of complex numbers}
\section{Function Analysis}
\section{Fourier Analysis}
\chapter{Algebar}
\section{Advanced Algebra}
\subsection{matrix}
\section{Abstract Algebra}
\section{Repersentation Theory}
\section{Commutative Algebra}
\section{Lie Algebra}
\section{Homological Algebra}
\chapter{Topology}
\chapter{Differential Equation}
\section{Ordinary Differential Equation}
\section{Partial Differential Equation}
\chapter{Geometry}
\chapter{Probability and Statistics}
\end{document}
按照惯例自答一下,非常感谢@Eureka 和@u19850 的倾情帮助。
首先分析下错因:
对于CASEA的写法,是使用自行在外部使用\keys_set:nn {<module>}{options}
的方式定义默认值,实际上这等价于在\keys_define:nn
内部使用<key>.initial
定义其赋值方式,这两种做法均会给option赋值初始值;
对于CASEB的写法,是使用<key>.code:n
会接受名为#1
的由<key>.default
定义的初始值<value>
,并执行code
的内容;但<key>.default:n
方法定义的default值仅仅是在value缺失时的默认值,如果option不被指定是不会被赋值的。
下面附interface3
中对这两个函数的介绍原文:
⟨key⟩ .default:n = {⟨default⟩}
Creates a ⟨default⟩ value for ⟨key⟩, which is used if no value is given. This will be used if only the key name is given, but not if a blank ⟨value⟩ is given.
key .default:n = xxx
, 是 value 缺失时的默认值
例如 key .default:n = xxx
,那么\keys_set:nn {mew}{key}
等价于\keys_set:nn {mew}{key = xxx}
⟨key⟩ .initial:n = {⟨value⟩}
Initialises the ⟨key⟩ with the ⟨value⟩, equivalent to\keys_set:nn {⟨module⟩} { ⟨key⟩ = ⟨value⟩ }
key .initial:n = xxx
, 等价于执行了 \keys_set:nn{mwe}{key = xxx}
鱼老师随便一句话就是标准的文档啊,无敌了!
作为一名learner,自然要分析下为什么上面的代码都不得行:
对于CASEA:
\cmd{Explorer}
输出了\l_mwe_opa_tl
以及\l_mwe_opb_tl
的默认值,因此首先输出了正常的结果。\cmd[opa=opa,opb=opb]{Explorer}
进入了\IfNoValueF
的条件逻辑中,此时(\l_mwe_opa_tl
,\l_mwe_opb_tl
)=(opa,opb),同时正常输出(opa,opb,Explorer)的内容\cmd[opa=opa]
只是制定了赋值\l_mwe_opa_tl=opa
,但由于\l_mwe_opa_tl
在上一个判断中已经被永久地赋值为了opb
,因此后文中并未将其恢复为defaultb
.(第31行同理)此时已经不难发现是一个变量作用域的问题,可以在自定义的命令\cmd
内使用\begin_group:
以及\end_group:
。事实上鱼老师再次一阵见血地指出:
"这种一般都要加group限制"
对于CASEA,此时只要加上限制,则可以解决上述问题。
而对于CASEB,可以如上分析:
\cmd{Explorer}
没有指定opa
和opb
,因此 此时default
值不会被赋值给key,code
的内容也不会输出,因此只输出了必须参数Explorer
opa=opa,opb=opb
,default值赋值之后被用于的opa=opa
覆盖,因此输出了(opa,opb,Explorer)opa=opa
,此时opa经历了先被赋值为defaulta
之后被用户选项覆盖为opa
,而opb
并未被invoked,因此只输出了(opa,Explorer);第24行同理只输出了(opb,Explorer).更改方式类似,加上group
后,用指定option而不赋值的方式调用,如下图:
暂时的最后(其实还要测试下雾月给出的lttemplates
方法),最后一下Eureka老师给出的一段代码(结合了CASEA与CASEB的做法):
本来还想分析的,凡是如果你有耐心看完上面一大段的话,是显然可以实现要求的。
自己给一个基于kayval
的解答。
\documentclass[12pt]{ctexart}
\usepackage[margin=1in]{geometry}
\setlength{\parindent}{0pt}
\usepackage{keyval}
\makeatletter
\def\mwe@vala{defaulta}
\define@key{mwe}{opa}{\def\mwe@vala{#1}}
\def\mwe@valb{defaultb}
\define@key{mwe}{opb}{\def\mwe@valb{#1}}
\newcommand\foo[2][]{
\begingroup
\setkeys{mwe}{#1}%
The opa is: \mwe@vala. \par
The opb is: \mwe@valb. \par
The Parameter is: #2. \par
\endgroup
}
\makeatother
\begin{document}
\foo{Explorer}
\foo[opa=opa,opb=opb]{Explorer}
\foo[opb=opb]{Explorer}
\foo[opa=opa]{Explorer}
\end{document}
请提供文本形式的代码,并用围栏代码块包裹,以方便调试。
另外,请你同步提供的learnlatex.bib
文件,以便可以让潜在的回答者一下载/复制就可以编译。
另附有关文档内容,你是否使用pdflatex-pdflatex-bibtex-pdflatex
方法编译?
使用\c_colon_str
替换即可,参考链接
\documentclass{article}
\usepackage{tikz}
\ExplSyntaxOn
\fp_new:N \l__skyrmion_rotate_fp
\fp_set:Nn \l__skyrmion_rotate_fp {30}
\cs_new_protected_nopar:Nn \l__skyrmion_tmp_cs:
{
\draw (0,0) -- (1,1)
node [ rotate~around = { \fp_use:N \l__skyrmion_rotate_fp \c_colon_str (0,0) } ] {test};
}
\ExplSyntaxOff
\begin{document}
\ExplSyntaxOn
\tikz { \l__skyrmion_tmp_cs: }
\ExplSyntaxOff
\end{document}
白嫖快乐~
请提供你的LaTeX
代码,而不只是一个word
截图,论坛的作用是帮助你修改你的代码,而不是像接单一样替你实现你的排版效果。
请展示你使用tabularray
宏包进行的尝试以及效果(体现你的付出和工作量),并提供规范的MWE。
在你的代码中涉及@
的内容前后加上\makeatletter
和\makeatother
,以处理@
的catcode的问题
\documentclass[openany]{book}
\usepackage{geometry}
\geometry{
papersize={10.5cm,14.85cm},
%showframe,
margin=1cm,
}
\makeatletter
\renewcommand{\part}{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\thispagestyle{empty}%
\if@twocolumn
\onecolumn
\@tempswatrue
\else
\@tempswafalse
\fi
\null\vfil
\secdef\@part\@spart}
\makeatother
\begin{document}
\setlength{\parindent}{2em}
\title{title}
\author{author}
\date{date}
\maketitle
\tableofcontents
\part{}
\chapter{}
Hello\TeX{}!
\part{}
\chapter{}
Hello\TeX{}!
\end{document}
另一种等价的更优雅的是使用\patchcmd
:
\usepackage{etoolbox}%
\patchcmd{\part}{\thispagestyle{plain}}{\thispagestyle{empty}}{}{}
问 在使用tse上“如何使所有文字变色”的方案后发现tasks包的环境内文字颜色并不会受影响