什么也不用做,正常写 \includegraphics{e2.emf}
就可以了,只要路径中有 e2.emf.pdf
这个文件即可。
什么也不用做,正常写 \includegraphics{e2.emf}
就可以了,只要路径中有 e2.emf.pdf
这个文件即可。
在 multitoc
宏包的问题,没有处理 false 分支的情况。
在它后面加上:
\makeatletter
\renewcommand*{\@starttoc}[1]{%
\ifthenelse{\boolean{@multitoc@toc}\and\equal{#1}{toc}}{%
\begin{multicols}{\multicolumntoc}%
\@multitoc@starttoc{#1}%
\end{multicols}%
}{%
\ifthenelse{\boolean{@multitoc@lot}\and\equal{#1}{lot}}{%
\begin{multicols}{\multicolumnlot}%
\@multitoc@starttoc{#1}%
\end{multicols}%
}{%
\ifthenelse{\boolean{@multitoc@lof}\and\equal{#1}{lof}}{%
\begin{multicols}{\multicolumnlof}%
\@multitoc@starttoc{#1}%
\end{multicols}%
}{\@multitoc@starttoc{#1}}%
}}}
\makeatother
这里提供三种方式,如果使用了 amsfonts
宏包可以用第二种,使用了 unicode-math
宏包可以用第三种。效果并不完全一样。
\newcommand\crossrightdasharrow{\mathrel{\ooalign{\hfil$\times$\hfil\cr
$\leaders\hbox to.75em{$-$\hss}\hskip2.25em\rightarrow$}}}
\usepackage{amsfonts}
\makeatletter
\newcommand\crossrightdasharrow{\mathrel{\ooalign{\hfil$\times$\hfil\cr
$\leaders\hbox to.45em{$\dabar@$\hss}\hskip2.25em\dabar@\mkern-5mu
\mathchar"0\hexnumber@\symAMSa 4B$}}}
\makeatother
\usepackage{unicode-math}
\setmathfont{Latin Modern Math} % 改成什么字体都行
\setmathfont[range={"D7,"279B,"23AF}]{XITS Math} % 这里最好保留,除非本来就是 XITS Math 字体
\newcommand\crossrightdasharrow{\mathrel{\ooalign{\hfil$\mkern-6mu\times$\hfil\cr
$\leaders\hbox to.4em{$\harrowextender$}\hskip2.4em
\rlap{$\harrowextender\mkern-3mu\harrowextender$}\draftingarrow$}}}
问题里长代码要换行再点上面的“代码”才可以正确输出代码,不然问题根本不能看。
第一个,\node
选项里的 \n
没展开,tikz 检测不到它的内容,要先展开:
\begin{tikzpicture}[x=2.5cm,y=-1.5cm,-stealth]
\foreach \x/\y/\m in {
1/1/H,
1/2/M,
2/1/K,
2/2/N}
{\node (\x\y)at(\x,\y){\m};}
\foreach \x/\y/\m/\n in
{
11/21/f/above,
12/22/g/below,
11/12/m/left,
21/22/n/right
}
{\expanded{\noexpand\draw(\x)--(\y)node[pos=.5,\n]{$\m$};}}
\end{tikzpicture}
第二个,\foreach \x/\y in {..} {\graph{\x->\y};}
相当于 \graph{\x->\y};\graph{\x->\y};..
,显然不等于 \graph{a1->a2->a3->a4}
。
你这个需求,手册上有一个例子:
可以用 /tikz/graph/parse
键:
\def\mychain#1{
\def\mytext{a1}
\foreach \x in {2,...,#1} {\xdef\mytext{\mytext->a\x}}
}
\tikzgraphsset{my chain/.style={
/utils/exec=\mychain{#1},
parse/.expand once=\mytext}
}
\begin{tikzpicture}
\graph {[my chain=4]};
\end{tikzpicture}
A 图,把线的颜色改为背景色,或设置透明度为 0 即可,这里采用的是第二种。注意 decoration 的透明度也会随之改变,要改回来。
B 图,由于 decoration 使用的坐标系是以路径的切线为 x 轴,法线为 y 轴,对于 sin 函数这个路径,即使是用的是同一个偏移向量(坐标),在画布上的实际偏移也不同。
对于这些圆,其上下两条包络线均不是正弦函数,但是最低点连成的曲线确实的正弦函数,这就是下图中的红色曲线。
\documentclass[margin=2pt]{standalone}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{backgrounds, decorations.markings, intersections, arrows.meta, positioning, calc, math, matrix}
\usetikzlibrary{shapes,calc,positioning}
\tikzset{every node/.style={aspect=0.2,cylinder, shape border rotate=90, draw}}
\tikzset{ Ap/.style={decoration={markings,mark=between positions 0 and 1 step 3mm with{#1}}, preaction={decorate}} }
\newcommand{\myarrowe}{\node [opacity=1,cylinder, cylinder uses custom fill,cylinder body fill=red!10,minimum height=2cm,text=gray!25] at (0,0.2) {};}
\newcommand{\myarrowy}{\node [cylinder, cylinder uses custom fill,cylinder body fill=gray!25,minimum height=2cm,text=gray!25,above=-0.25cm] at (0,0) {};}
\newcommand{\myarrowt}{\shade[ball color=blue!80!white](0,0) circle (0.25cm);}
\newcommand{\myarrowp}{\shade[ball color=red!80!white](0,0.25) circle (0.25cm);}
\begin{document}
\begin{tikzpicture}[domain=0:5, samples=100]
\node[]at (2,2.5){A};
\draw[opacity=0,Ap=\myarrowe] plot(\x, 0.85);
\draw[Ap=\myarrowp,ultra thick] plot(\x, 0);
\end{tikzpicture}
\begin{tikzpicture}[domain=0:6.28, samples=100]
\node[]at (3,3.5){B};
\draw[Ap=\myarrowy] plot(\x, {sin(\x r)});
\draw[opacity=0,Ap=\myarrowt] plot(\x, {sin(\x r)});
\draw[ultra thick,draw=red] plot(\x, {sin(\x r)-0.25});
\end{tikzpicture}
\end{document}
这里 B 图圆柱轴线是穿过当前蓝球的球中心的,把球的半径改小,能发现它们嵌于圆柱的中间。
XeLaTeX 下,xeCJK
可以使用 \xeCJKDeclareCharClass
全局的更改某个字符的字符类。你可以改了之后再改回来。
LuaLaTeX 下,luatexja
不支持修改 U+00 — U+7F 的 charrange。
问题出在 \newtheorem
并不会展开第 2 个参数,所以保留的是 \l_theorem_chinese_tl
的最后一个定义。
这里提供使用 \keyval_parse:nnn
的方法,比用 prop 更为简洁、快速。
\ExplSyntaxOn
% 使用方法 \addtheorem{<style>}{<environment name>=<Chinese name>, <environment name>, ...}
\NewDocumentCommand \addtheorem { m m }
{
\tl_set:Nn \l_theorem_style_tl {#1}
\keyval_parse:nnn { \__theorem_new_theorem:nn { } } { \__theorem_new_theorem:nn } {#2}
}
\cs_new:Npn \__theorem_new_theorem:nn #1#2
{
\theoremstyle { \l_theorem_style_tl }
\tl_if_empty:nTF {#1}
{
\exp_last_unbraced:Ne \newtheorem { {#2} { \text_titlecase_first:n {#2} } }
\exp_last_unbraced:Ne \newtheorem { * {#2*} { \text_titlecase_first:n {#2} } }
}
{
\newtheorem {#1} {#2}
\newtheorem * {#1*} {#2}
}
}
\ExplSyntaxOff
还额外支持没有给出 <chinese name>
的情况,此时把 <environment name>
第一个字母大写作为 <chinese name>
。如果不想要这个特性,把 \tl_if_empty:nTF
的 true 分支删掉即可。
比如:
\addtheorem{definition}{
definition = 定义,
assume = 假设,
lemma = 引理,
question = 问题,
corollary
}
\addtheorem{remark}{
remark = 注
}
如果不知道某一个命令会不会展开它的参数,最好的解决办法是先展开参数(用 \exp_args:N..
或 \exp_last_unbraced:N..
),再传递给这个命令。
第一,你的这个代码逻辑有问题。
第二,tblr
不会自动展开它的内容,必须使用 expand
选项设置要展开的命令,否则这个命令的内容会进入到某一个单元格中。
代码并不复杂:
\ExplSyntaxOn
\tl_clear:N \l_my_tmp_tl
\int_step_inline:nnn { 0 } { 18 }
{
\tl_put_right:Nn \l_my_tmp_tl
{ $ \sin #1^\circ = \fp_eval:n { sin( #1 * \c_one_degree_fp ) } $ }
\int_compare:nNnTF { \int_mod:nn { #1+1 } { 3 } } = { 0 }
{ \tl_put_right:Nn \l_my_tmp_tl { \\ } }
{ \tl_put_right:Nn \l_my_tmp_tl { & } }
}
\centering
\begin{tblr}[expand=\l_my_tmp_tl]{|c|c|c|}
\l_my_tmp_tl
\end{tblr}
\par
\ExplSyntaxOff
另一种排布:
\tl_clear:N \l_my_tmp_tl
\seq_clear:N \l_my_tmpa_seq
\seq_clear:N \l_my_tmpb_seq
\seq_clear:N \l_my_tmpc_seq
\int_step_inline:nnn { 7 } { 12 }
{
\seq_put_right:Nn \l_my_tmpb_seq
{ $ \sin #1^\circ = \fp_eval:n { sin( #1 * \c_one_degree_fp ) } $ }
}
\int_step_inline:nnn { 13 } { 18 }
{
\seq_put_right:Nn \l_my_tmpc_seq
{ $ \sin #1^\circ = \fp_eval:n { sin( #1 * \c_one_degree_fp ) } $ }
}
\int_step_inline:nnn { 0 } { 6 }
{
\tl_set:Nn \l_my_tmpa_tl { $ \sin #1^\circ = \fp_eval:n { sin( #1 * \c_one_degree_fp ) } $ }
\seq_pop_left:NNF \l_my_tmpb_seq \l_my_tmpb_tl
{ \tl_set_eq:NN \l_my_tmpb_tl \c_empty_tl }
\seq_pop_left:NNF \l_my_tmpc_seq \l_my_tmpc_tl
{ \tl_set_eq:NN \l_my_tmpc_tl \c_empty_tl }
\tl_put_right:Nx \l_my_tmp_tl
{ \exp_not:o \l_my_tmpa_tl & \exp_not:o \l_my_tmpb_tl & \exp_not:o \l_my_tmpc_tl \exp_not:N \\ }
}
\begin{tblr}[expand=\l_my_tmp_tl]{|c|c|c|}
\l_my_tmp_tl
\end{tblr}
\par
另外,TeX 的计算结果并不一定十分准确,专业的计算交给专业的软件。
在 LaTeX2e 中有 \newcommand{\...}[num]{...}
,这种用法,\cs_generate_from_arg_count:NNnn
是对它的一个扩展。
这个函数是有用的,例如,\cs_set:Nn
可以这样定义:
先得到要定义的函数的 signature(比如:\cs_set:Npn
中的 Npn
),然后计算 signature 中的字符数,再由 \cs_generate_from_arg_count:NNnn
生成。
另一个例子是 \NewDocumentCommand
的定义。例如 \NewDocumentCommand \cs { mm } {...}
,可以看出 \cs
接受 2 个参数,直接使用 \cs_generate_from_arg_count:NNnn \cs \cs_new_protected_nopar:Npn { 2 } {...}
定义即可(当然,实际上更加复杂)。
外面的盒子自己改。用 tikz
、tcolorbox
都可以。改颜色、字体、\parttocbox
\chaptertocbox
\chaptertocdashed
即可,其它的基本不用改。
目前的效果是这样:
\documentclass{ctexbook}
%\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{paracol}
\usepackage{etoc}
\usepackage{calc}
\usepackage{varwidth}
%\usepackage{hyperref}
\begin{document}
\makeatletter
\newlength{\parttocsep}
%%%---只需改这中间的即可,如果要改间距再改后面的
\newcommand{\toccolorlist}{black,red!70,green!30!black,cyan,black!70}
%% 颜色自己加,使用逗号分割即可,在目录中 \tocthecolor 保存了当前值
\setlength{\parttocsep}{12pt plus 4pt minus 4pt}
% #1=number, #2=name, #3=page
\newcommand{\parttocbox}[3]{\zihao{-3}\fbox{#3}\hfill
\parbox[t]{.7\columnwidth}{#1\par \large #2}}
\newcommand{\chaptertocbox}[3]{%
\fbox{\parbox{2em}{#1}%
\begin{varwidth}{\linewidth-4em}#2\end{varwidth}}\hfill#3}
\newcommand{\chaptertocdashed}{\noindent\makebox[\columnwidth]{\dotfill}}
\newcommand{\tocinitials}{\columnratio{.33}
\twosided[m]%
\setlength{\columnseprule}{3pt}% 中间的线宽
\setlength{\parindent}{0pt}}
\newcommand{\parttoccode}{{\parttocbox{Part \etocnumber}{\etocname}{\two@digits{\etocthepage}}\par}}
\newcommand{\chaptertoccode}{{\chaptertocbox{\etocnumber}{\etocname}{\etocpage}\par}}
\newcommand{\sectiontoccode}{\@dottedtocline{1}{3em}{3.7em}{\etocnumber\enskip\etocname}{\etocpage}}
\newcommand{\subsectiontoccode}{\@dottedtocline{2}{6.7em}{2.6em}{\etocnumber\etocname}{\etocpage}}
\newcommand{\subsubsectiontoccode}{\@dottedtocline{3}{6.7em}{2.6em}{\etocnumber\etocname}{\etocpage}}
%%%---
\ExplSyntaxOn
\tl_set:Nn \tocthecolor {black}
\cs_new_protected:Npn \toccolor #1
{
\tl_set:Nx \tocthecolor
{
\clist_item:Nn \toccolorlist
{ \int_mod:nn {#1} { \clist_count:N \toccolorlist } + 1 }
}
\normalcolor
}
\ExplSyntaxOff
\newcommand{\tocnumberline}[1]{%
\protect\numberline{\CTEXifname{\number\value{#1}}{0}}}
%% 必须留着
\ctexset{part/tocline=\tocnumberline{part}{#2},
chapter/tocline=\tocnumberline{chapter}{#2},
section/name={第,节},section/number=\arabic{section},
subsection/number={\thesection.\arabic{subsection}},}
\renewcommand*{\thesection}{\arabic{chapter}.\arabic{section}}
\counterwithin{chapter}{part}
\begingroup
\etocsetstyle{part}
{}
{\@bsphack\tocinitials\@esphack
\def\normalcolor{\color{\tocthecolor}}%
\etociffirst{}{\addvspace{\parttocsep}}%
\begin{paracol}{2}}
{\switchcolumn[0]* \toccolor{\etocthenumber}\parttoccode}
{}
\etocsetstyle{chapter}
{\switchcolumn \nointerlineskip}
{\etociffirst{}{\par\chaptertocdashed\par}}
{\chaptertoccode\par \prevdepth-\@m\p@ \vspace{1ex+\lineskip}\par}
{\end{paracol}}
\etocsetstyle{section}
{\par}
{}
{\sectiontoccode}
{\par\prevdepth-\@m\p@ \vspace{1ex+\lineskip}\par}
\etocsetstyle{subsection}
{\par}
{}
{\subsectiontoccode}
{\par}
\etocsetstyle{subsubsection}
{\par}
{}
{\subsubsectiontoccode}
{\par}
\tableofcontents
\endgroup
\makeatother
\part{一个部分}
\chapter{介绍}
\section{引言}
\chapter{简明教程}
\part{编译方式、编码与字库}
\chapter{常见的编译方式有哪些}
\chapter{不同的编码}
\chapter{字库}
\part{章节标题设置方式大全}
\chapter{章节标题样式设计大全(不使用宏包直接设置方法)}
\section{编号相关}
\section{格式相关}
\section{间距相关}
\section{目录、附录}
\subsection{小小节但是名字很长的节}
\subsection{小心地}
\section{很长很长很长很长很长的标题怎么设置}
\chapter{章节标题样式设计大全(宏包)}
\chapter{一分为二的标题}
\chapter{一些样式}
\part{长标题是怎样排版的?长标题是怎样换行的?}
\chapter{长标题要断行该使用什么样的命令或环境呢?}
\chapter{短标题}
\chapter{不得使用titlesec宏包}
\chapter{直接用ctex设置}
\chapter{1234567}
\end{document}
使用 etoc
宏包,虚线见 https://ask.latexstudio.net/ask/question/7397.html 。
\documentclass{ctexrep}
\usepackage{enumitem}
\usepackage{etoc}
%\usepackage[colorlinks]{hyperref}
\setmainfont{TeX Gyre TermesX}
\usepackage{dashrule}
\begin{document}
\ExplSyntaxOn
% https://ask.latexstudio.net/ask/question/7397.html
\NewDocumentCommand \approxhdashrule { O{0pt} m m m }
{
\hbox_to_wd:nn {#2}
{
\int_set:Nn \l_tmpa_int
{
2 * \int_div_round:nn { \int_value:w \tex_dimexpr:D #2 }
{ 2 * \int_value:w \tex_dimexpr:D #4 } + 1
}
\dim_set:Nn \l_tmpa_dim { \dim_eval:n {#2} / \l_tmpa_int }
\hdashrule [#1] {#2} {#3} { \l_tmpa_dim }
\hbox_overlap_left:n { \rule [#1] { \l_tmpa_dim } {#3} }
}
}
\ExplSyntaxOff
\ctexset{section/tocline={\protect\numberline{第\chinese{section}节}#2}}
\makeatletter
\newlist{thetoclist}{itemize}{5}
% chapter
\setlist[thetoclist,1]{nosep,label=\etocnumber,
left=0cm..5\ccwd,labelsep=1\ccwd}
% section
\setlist[thetoclist,2]{nosep,label=\etocnumber,
left=5\ccwd..4\ccwd,labelsep=1\ccwd}
\newcommand{\thetoc@dashed}{\noindent
\approxhdashrule[.6ex]{\linewidth}{.6pt}{4pt}\par}
\let\thetocdashed\relax
\providecommand{\three@digits}[1]{\ifnum#1<10 0\fi
\ifnum#1<100 0\fi \number#1 }
\etocsetstyle{chapter}
{\begin{thetoclist}}
{\etociffirst{}{\thetoc@dashed}%
\rmfamily\bfseries\item}
{\etocname\hfill \slshape\three@digits\etocthepage}
{\end{thetoclist}}
\etocsetstyle{section}
{\begin{thetoclist}}
{\normalfont\item}
{\etocname\hfill \slshape\three@digits\etocthepage}
{\end{thetoclist}}
\localtableofcontents
\makeatother
\cleardoublepage
\pagenumbering{arabic}
\chapter{双相障碍及精准医学}
\section{双相障碍概念}
\section{精准医学概念}
\chapter{双相障碍的临床表现}
\section{临床表现及分型}
\section{抑郁发作}
\setcounter{chapter}{10}
\chapter{双相障碍的病因机制假说}
\section{遗传与环境交互作用假说}
\end{document}
\documentclass{article}
\usepackage{enumitem}
\makeatletter
\newcommand\twodigitsarabic[1]{\two@digits{\value{#1}}}
\AddEnumerateCounter{\twodigitsarabic}{\@arabic}{99}
\makeatother
\begin{document}
\begin{enumerate}[label={\twodigitsarabic*.}]
\item content
\item content
\item content
\end{enumerate}
\end{document}
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat*}{3}
&& \| S+T \|^{2}_{A}& = \omega ^{2}_{A}(S+T) && \\
&& & \leq \sup_{\|x\|_{A}=1}(|\langle (S+iT)x,x \rangle _{A} |^{2} && \\
&& & & \text{\llap{(by Lemma)}} & \\
&& & \leq \sup_{\|x\|_{A}=1}(|\langle (S+iT)x,x \rangle _{A} |^{2} && \\
\end{alignat*}
\end{document}
我没有下载 texstudio,
你可以换成 \lstinline|...|
试试,
不行再改成
\newcommand\myinline{\lstinline}
\myinline{...}
试试。
目前,TeX 的代码高亮不可能做到像其它编程语言的一样好。
ctex
在 pdftex 下使用 CJK
宏包,应该是和 newunicodechar
不兼容的。
\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{newunicodechar}
\DeclareUnicodeCharacter{1F994}{\LaTeX}
\begin{document}
what?
????%% <-- U+1F994
\end{document}
这个可以在 pdftex 下编译,但改成 ctex 文档类就不行了。
问 图片格式转换映射\DeclareGraphicsRule