declare function看文档似乎只能允许一元的输出...
如果重复使用这个坐标就要写很多次了,虽然可以复制粘贴,但是不太优雅
我一般的做法是\pgfmathsetmacro:
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \ii in {0, 1, ..., 5}{
\foreach \jj in {0, 1, ..., 4}{
\pgfmathsetmacro{\x}{\ii+\jj*0.5}
\pgfmathsetmacro{\y}{-\jj*0.8}
\node at (\x,\y) {$(\ii,\jj)$};
}
}
\end{tikzpicture}
\end{document}或者\fpeval?
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \ii in {0, 1, ..., 5}{
\foreach \jj in {0, 1, ..., 4}{
\def\x{\fpeval{\ii+\jj*0.5}}
\def\y{\fpeval{-\jj*0.8}}
\node at (\x,\y) {$(\ii,\jj)$};
}
}
\end{tikzpicture}
\end{document}利用luadraw还挺简单的,要实现「要求取点多但网格线少」好像也只要改一个参数...
\documentclass{standalone}
\usepackage[svgnames]{xcolor}
\usepackage[3d]{luadraw}
\usepackage{fourier}
\begin{document}
\begin{luadraw}{name=saddle}
local g = graph3d:new{
window3d={-2,2,-2,2,-2,2},
adjust2d=true,size={10,10}
}
local f = function(x,y) return 0.3*(x*x - y*y) end
local s = cartesian3d(f, -1.5, 1.5, -1.5, 1.5,{10,10})
-- The function cartesian3d(f, x1, x2, y1, y2 [, grid, addwall])
-- change the parameter grid to get less facets
g:Dboxaxes3d{grid=true}
g:Dfacet(s, {color="Orange", mode=mShaded})
g:Show()
\end{luadraw}
\end{document}
仅作示范,可以画两次,第二次不要画额外的轴:
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{set layers}
\begin{axis}[
scale only axis,
width=10cm, height=6cm,
ybar, bar width=12pt,
ylabel={Production (10k tons)},
symbolic x coords={1-2, 1-3, 1-4, 1-5, 1-6, 1-7, 1-8, 1-9},
xtick=data,
ymin=0, ymax=8000,
axis y line*=left,
legend style={at={(0.5,-0.15)}, anchor=north, legend columns=-1},
area style
]
\addplot[fill=white, draw=black] coordinates {
(1-2, 1149) (1-3, 1744) (1-4, 2314) (1-5, 2905)
(1-6, 3526) (1-7, 4111) (1-8, 4672) (1-9, 5263)
};
\addplot[fill=gray!60, draw=black] coordinates {
(1-2, 1527) (1-3, 2362) (1-4, 3143) (1-5, 3939)
(1-6, 4792) (1-7, 5584) (1-8, 6348) (1-9, 7160)
};
\legend{Pig Iron, Crude Steel}
\end{axis}
\begin{axis}[
scale only axis,
width=10cm,height=6cm,
axis y line*=right,
axis x line=none,
ylabel={Growth Rate (\%)},
ymin=0, ymax=16,
symbolic x coords={1-2, 1-3, 1-4, 1-5, 1-6, 1-7, 1-8, 1-9}
]
\addplot[mark=square*,thick] coordinates {
(1-2, 7.1) (1-3, 8.0) (1-4, 6.8) (1-5, 5.8)
(1-6, 5.6) (1-7, 5.4) (1-8, 5.0) (1-9, 4.9)
};
\addplot[mark=triangle*,thick] coordinates {
(1-2, 13.7) (1-3, 11.0) (1-4, 8.7) (1-5, 8.2)
(1-6, 9.3) (1-7, 9.5) (1-8, 9.3) (1-9, 9.3)
};
\end{axis}
\end{tikzpicture}
\end{document}
我不太确定这是否会造成其他恶劣影响,建议不要使用。
来自我的这个提问。
\documentclass{article}
\usepackage[fontset=fandol]{ctex}
\usepackage{amsmath,amsfonts}
% https://ask.latexstudio.net/ask/question/17856.html
\begin{document}
电磁学与电动力学的区别:
\makeatletter
\[
\def\env@cases{%
\let\@ifnextchar\new@ifnextchar
\left\lbrace
\def\arraystretch{0.5}%
\array{@{}l@{\quad}l@{}}%
}
\makeatother
\begin{cases}
\text{电磁学:数学语言比较简单,通常只利用积分}
\vspace{10ex}\\
\text{电动力学:大量使用矢量微分运算}
\end{cases}
\]
\[
y = \begin{cases}
x+y+z \\
x^2+y^2+z^2
\end{cases}
\]
\end{document}
Notes: 永远不要在LaTeX里用$$...$$,使用\[...\]。详见这里。




(这里我不太确定要不要重启,可以试试...)

\documentclass{standalone}
\usepackage[3d]{luadraw}
\usepackage[svgnames]{xcolor}
\begin{document}
\pgfdeclareradialshading[]{sphereDay}{\pgfpoint{20 bp}{0 bp}}
{color(0bp)=(orange!10); color(20bp)=(orange!50); color(38bp)=(orange)}%
\pgfdeclareradialshading[]{sphereNight}{\pgfpoint{50 bp}{0 bp}}
{color(0bp)=(DarkBlue!10); color(15bp)=(DarkBlue!70); color(38bp)=(black)}%
\begin{luadraw}{name=earth_light_half}
local g = graph3d:new{
window3d={-5, 5, -5, 5, -5, 5},
window={-5 , 10, -5 ,5},
size={8, 8},viewdir={90, 80}
}
require "luadraw_spherical"
local O, R = Origin, 4
Hiddenlines = true
Hiddenlinestyle = "dashed"
g:Define_sphere({radius=R, show=false})
local thetaA, thetaB = 22.5, 67.5
-- plot the latitudes
for _,i in ipairs({90-thetaA, 90-thetaB, 90+thetaA, 90+thetaB})do
local lat = sM(0,i)
g:DScircle({lat,vecK}, {color="magenta", width=4})
end
-- plot the equator
g:DSbigcircle({vecI,vecJ},{style="dashed", color="teal", width=5})
-- plot the axis
g:DSseg({ M(0,0,-1.25*R), M(0,0,1.25*R) }, {width=10})
-- two hemispheres outlines
local A, B = Z(0,R), Z(0,-R)
g:Dpath({ B, "m", 0, A, R, -1, "ca"}, "color=DarkGray, shading=sphereNight")
g:Dpath({ B, "m", 0, A, R, 1, "ca"}, "color=DarkGray, shading=sphereDay")
g:Rotate3d(-22.5, {Origin,vecJ})
g:Dspherical()
local dt = 25*deg
for k = 0, 4 do
local z = Zp(R+1,(k-2)*dt)
g:Dpolyline({Z(10,z.im), z}, false, "-latex,thick,teal")
end
g:Show()
\end{luadraw}
\end{document}
术业有专攻,应该找找建筑设计行业的「最佳实践」。

试了一下现有的宏包, 都相去甚远, 有没有什么好的宏包推荐一下呢?
从代码的注释里我只看到了纯AI的痕迹,没看到太多尝试。而且这个图从构图来看并不存在很大的技术难点,只是细节多,绘制繁琐。
说实话用TikZ画这种图的意义几乎为零。
其实我感觉语法没有比tikz-3d简单,反而求两个大圆交点(在luadraw-v2.6)需要花点心思...
% https://github.com/pfradin/luadraw/discussions/223#discussioncomment-16064759
\documentclass{standalone}
\usepackage[3d]{luadraw}
\usepackage[svgnames]{xcolor}
\usepackage{fourier}
\begin{document}
\begin{luadraw}{name=spherical_geometry}
local g = graph3d:new{window3d={-5, 5, -5, 5, -5, 5},window={-3,4.25,-3,4}, viewdir={30, 65}, size={12, 12}}
require 'luadraw_spherical'
local O,R = Origin,4
g:Define_sphere({radius=R, show=false, opacity=1})
local Pz, Px, Py = sM(0,0), sM(0,90), sM(90,90)
local theta = 55
local A, B = sM(theta, 90), Py
local D = sM(90,65)
local M = 0.7 * D
local N = pxy(M)
-- calculus of C and K
-- The function plane(A,B,C) returns the plane passing through the three 3d points A, B, and C (if they are not aligned,otherwise the result is nil).
local d = interPP( plane(O,Px,D), plane(O,A,Pz) )
-- the intersection of two planes is line OC
-- d[2] is a direction vector of the line d
-- where d is the line in form {A,u}, the normalized direction vector
local C = R*pt3d.normalize(d[2])
local K = pxy(C) -- projection of C on the plane Oxy
Hiddenlines = true;Hiddenlinestyle = "dashed"
g:Linestyle("dashed")
-- g:DSarc({Pz, Px}, 1)
-- g:DSarc({Pz, Py}, 1)
-- g:DSarc({Px, Py}, 1)
-- g:DSarc({Px, D}, 1)
-- g:DSarc({Pz, A}, 1)
for _, arc in ipairs({{Pz, Px}, {Pz, Py}, {Px, Py}, {Px, D}, {Pz, A}}) do
g:DSarc(arc, 1)
end
-- g:DSseg({O, Pz})
-- g:DSseg({O, Px})
-- g:DSseg({O, Py})
-- g:DSseg({N, K})
-- g:DSseg({M, N})
g:DSpolyline({{Px,O,Pz},{M,N,K},{O,B}})
g:Linestyle("solid"); Hiddenlinestyle = "solid"
g:DSseg({O, A})
g:DSseg({O, D})
g:DSseg({O, C})
g:DSseg({C, K})
g:DSseg({C, M})
g:DSarc({A, B}, 1)
g:DSdots({O,A,D,M,N},{mark_options="teal"})
g:DSstars({Pz, Px, Py}, {color="magenta",fill="magenta", scale=0.75})
g:Dspherical()
g:Dlabel3d(
"$O$", O, {pos="W"},
"$A$", A, {pos="S"},
"$B$", B, {pos="E"},
"$C$", C, {pos="NW"},
"$D$", D, {pos="NE"},
"$K$", K, {pos="W"},
"$M$", M, {pos="N"},
"$N$", N, {pos="NE"}
)
g:Show()
\end{luadraw}
\end{document}
这个模板只有一些文件名不匹配的小问题,自行修改即可。
也许是精度误差(?)
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\node {\fpeval{tand(45)} v.s. \pgfmathparse{tan(45)}\pgfmathresult};
\end{tikzpicture}
\end{document} 
By @u115385
希望在书签里能显示出subsubsection默认情况下就能显示出subsubsection...请展示你「不能体现出subsubsection书签」的具体截图。
\documentclass[fontset=fandol]{ctexart}
\usepackage{hyperref}
\begin{document}
\section{单词}
\subsection{词汇}
\subsubsection{二级词汇}
\end{document}
并且把\words{...}中的单词放入书签显示,与subsection或subsubsection同一层次.
我没有这个字体,字体问题显然与是不是在书签显示,是不是同一层次无关。

加上hyperref提供的\pdfbookmark命令即可。其中level的含义是自解释的。
\documentclass[fontset=fandol]{ctexart}
\usepackage{hyperref}
\usepackage{xcolor}
\newcommand{\words}[1]{\pdfbookmark[2]{#1}{word:#1}\noindent{\huge\textbf{\textcolor{red}{#1}}~~}}
% \newcommand{\words}[1]{\pdfbookmark[2]{#1}{work:#1}\noindent{\huge\textbf{\textcolor{red}{\fontspec{Avenir}#1}}~~}}
\begin{document}
\section{单词}
\subsection{词汇}
\subsubsection{二级词汇}
\words{chenchen}
\words{辰辰}
\words{你好}
\end{document}
另外,我不觉得单词应该与\subsection或者\subsubsection同level.
与原文的最大差异是12pt的字体相对于版面太大了,改用默认的10pt并微调\item[]的定义即可:
\algnewcommand\algorithmicinput{\textbf{Input:}}
\algnewcommand\Input[1]{\item[\,\algorithmicinput]\ #1}
\algnewcommand\algorithmicoutput{\noindent\textbf{Output:}}
\algnewcommand\Output[1]{\item[\,\algorithmicoutput]\ #1}完整代码:
\documentclass[a4paper]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{algorithm}
\usepackage{algpseudocode}
\algnewcommand\algorithmicinput{\textbf{Input:}}
\algnewcommand\Input[1]{\item[\,\algorithmicinput]\ #1}
\algnewcommand\algorithmicoutput{\noindent\textbf{Output:}}
\algnewcommand\Output[1]{\item[\,\algorithmicoutput]\ #1}
\pagestyle{empty}
\begin{document}
\lipsum[1]
\medskip
\noindent\begin{minipage}{.49\textwidth}%
\begin{algorithm}[H]
\centering
\caption{SSM(S4)}
\begin{algorithmic}[1]
\Input{$x:(B,L,D)$}
\Output{$y:(B,L,D)$}
\State $A:(D,N) \leftarrow \text{Parameter}$ \par \Comment{$\text {Represents structured}\ \ N \times N\ \ \text{martix}$}
\State $B:(D,N) \leftarrow \text{Parameter}$
\State $C:(D,N) \leftarrow \text{Parameter}$
\State $\Delta:(D) \leftarrow \tau_\Delta(\text{Parameter})$
\State $\bar{A},\bar{B}:(D,N) \leftarrow \text{discretize}(\Delta,A,B)$
\State $y \leftarrow \text{SSM}(\bar{A},\bar{B},C)(x)$ \par
\Comment{Time-invariant: recurrence or convolution}
\State \textbf{return} y
\end{algorithmic}
\end{algorithm}%
\end{minipage}\hfill%
\begin{minipage}{.49\textwidth}%
\begin{algorithm}[H]%
\centering
\caption{SSM+Selection(S6)}
\begin{algorithmic}[1]
\Input{$x:(B,L,D)}$
\Output{$y:(B,L,D)$}
\State $A:(D,N) \leftarrow \text{Parameter}$ \par \Comment{$\text{Represents structured}\ \ N \times N\ \ \text{martix}$}
\State $B:\textcolor{red!90!black}{(B,L,N)} \leftarrow \textcolor{red!90!black}{s_B(x)}$
\State $C:\textcolor{red!90!black}{(B,L,N)} \leftarrow \textcolor{red!90!black}{s_C(x)}$
\State $\Delta:\textcolor{red!90!black}{(B,L,D)} \leftarrow \tau_\Delta(\text{Parameter}+\textcolor{red!90!black}{s_\Delta(x)})$
\State $\bar{A},\bar{B}:(B,L,D,N) \leftarrow \text{discretize}(\Delta,A,B)$
\State $y \leftarrow \text{SSM}(\bar{A},\bar{B},C)(x)$ \par
\Comment{\textcolor{red!90!black}{Time-varying}: recurrence (\textcolor{red!90!black}{scan}) only}
\State \textbf{return} y
\end{algorithmic}
\end{algorithm}
\end{minipage}%
\medskip
\lipsum[2]
\end{document}
基于schemata宏包不做任何微调的话:
\documentclass[border=5pt]{standalone}
\usepackage[fontset=fandol]{ctex}
\usepackage{schemata}
\begin{document}
\schema
{
\schemabox{1 一级标题}
}
{
\schema
{
\schemabox{1.1 二级标题}
}
{
\schema
{
\schemabox{1.1.1 三级标题}
}
{
\schemabox{1.1.1.1 四级标题}
\schemabox{1.1.1.2 四级标题}
}
\schema
{
\schemabox{1.1.2 三级标题}
}
{
\schemabox{1.1.2.1 四级标题}
\schemabox{1.1.2.2 四级标题}
}
}
\schema
{
\schemabox{1.2 二级标题}
}
{
\schema
{
\schemabox{1.1.1 三级标题}
}
{
\schemabox{1.1.1.1 四级标题}
\schemabox{1.1.1.2 四级标题}
}
\schema
{
\schemabox{1.1.2 三级标题}
}
{
\schemabox{1.1.2.1 四级标题}\smallskip
\schemabox{\parbox{8em}{\linespread{1.0}\selectfont 文字文字文字文字文字文字文字文字文字文字文字文字}}
}
}
}
\end{document}
修改\Schema[⟨type⟩]{⟨adjust⟩}{⟨size⟩}调整brace的位置:
\documentclass[border=5pt]{standalone}
\usepackage[fontset=fandol]{ctex}
\usepackage{schemata}
\begin{document}
\Schema{-2ex}{8ex}
{
\schemabox{1 一级标题}
}
{
\Schema{0ex}{4.5ex}
{
\schemabox{1.1 二级标题}
}
{
\schema
{
\schemabox{1.1.1 三级标题}
}
{
\schemabox{1.1.1.1 四级标题}
\schemabox{1.1.1.2 四级标题}
}
\schema
{
\schemabox{1.1.2 三级标题}
}
{
\schemabox{1.1.2.1 四级标题}
\schemabox{1.1.2.2 四级标题}
}
}
\Schema{-1.5ex}{5.5ex}
{
\schemabox{1.2 二级标题}
}
{
\schema
{
\schemabox{1.1.1 三级标题}
}
{
\schemabox{1.1.1.1 四级标题}
\schemabox{1.1.1.2 四级标题}
}
\schema
{
\schemabox{1.1.2 三级标题}
}
{
\schemabox{1.1.2.1 四级标题}\smallskip
\schemabox{\parbox{8em}{\linespread{1.1}\selectfont 文字文字文字文字文字文字文字文字文字文字文字文字}}
}
}
}
\end{document}
(OS.其实我感觉这个语法也并不优雅...不如forest...难用,不够自动化...)
问 使用forest宏包排版树状结构图对于多行文本如何保持节点的对齐?