Sagittarius Rover
Sagittarius Rover
这家伙很懒,什么也没写!

注册于 3年前

回答
523
文章
0
关注者
21

hspan=minimal is all I need, actually...

对文档还是不够熟悉(摇头...)

image.png

\documentclass[12pt]{article}
\usepackage[fontset=fandol]{ctex}
\usepackage[showframe,a4paper,hmargin=1.25cm]{geometry}
\usepackage{tabularray}
\UseTblrLibrary{booktabs,varwidth}
\setlength{\parindent}{0pt}
\usepackage{lipsum}
\begin{document}

\begin{tblr}{
    colspec={X[1.25,c,m]X[1.75,c,m]X[1,c,m]X[1.5,c,m]X[1.75,c,m]},
    hlines,vlines,
    hline{1,Z} = {2pt},
    vline{1,Z} = {2pt},
    width=\linewidth,
    measure=vbox,
    hspan=minimal,
    rows = {ht=1cm},
    row{3} = {ht=2.5cm},
    row{X-Y} = {ht=3cm},
    cell{1}{1-Y} = {r=2}{valign=m},
    cell{2}{Z} = {r=3}{valign=m},
    cell{3}{2} = {c=3}{valign=m},
    cell{5-Z}{2} = {c=4}{halign=l,valign=m},
    cell{X-Y}{2} = {valign=h},
}
课程名称 & & {学\quad 分} & & {总计:\qquad 学时} \\
& & & & {\linespread{1.75}\selectfont 讲课:\qquad 学时\\讲课:\qquad 学时\\讲课:\qquad 学时\\讲课:\qquad 学时\\讲课:\qquad 学时\\} \\
{课程性质\\[10pt](请打勾)} & %
{\linespread{1.5}\selectfont%<- important % hete
    通识必修课(\quad)\ 通识选修课(\quad)\ 专业必修课(\quad)\\
    通识必修课(\quad)\ 通识选修课(\quad)\ 专业必修课(\quad)\\
    通识必修课(\quad)\ 通识选修课(\quad)\ 专业必修课(\quad)\\
}  
&  &  &  \\
任课老师 &  & 职称 &  &  \\
授课对象 & 年级、专业: &  &  &  \\
课程目标 &  &  &  &  \\
教学重难点 &  &  &  &  \\
% 教材 & {教材:} &  &  &  \\
% 参考资料 & {参考资料:} &  &  &  \\
教材 & {教材:\lipsum[2][1-6]} &  &  &  \\
参考资料 & {参考资料:\lipsum[2][1-6]} &  &  &  \\
其他要求 &  &  &  &  \\
\end{tblr}

\bigskip

Notes: \lipsum[2][1-5]

\end{document}

image.png

使用需要lualatextkz-elements包(v5.13c)在处理椭圆切线等问题会方便很多:

\documentclass[border=5pt]{standalone}
\usepackage[mini]{tkz-euclide}
\usepackage{tkz-elements}
\directlua{
    init_elements()
    z.O = point(0.15, 0.6) 
    C.OW = circle(through(z.O, 0.5))
    z.W = C.OW.through
    z.M = point(-0.25, -1)
    z.N = point(1,4)
    z.C = tkz.midpoint(z.M, z.N)
    L.MN = line(z.M, z.N)
    z.T = L.MN:orthogonal_at(z.C, {length = 1.5})
    CO.EL = conic(EL_points(z.C, z.N, z.T))
    PA.curve = CO.EL:points(0, 1, 100)
    z.P = point(4,-1)
    L.tan, _ = CO.EL:tangent_from(z.P)
    z.Q = L.tan.pb
    L.normal = L.tan:ortho_from(z.Q)
    z.dir = L.normal:report(-1.5, z.Q)
    z.H = line(z.P, z.Q):projection(z.O)
    z.v, _ = intersection(line(z.O,z.Q), C.OW)
    z.u, _ = intersection(line(z.O,z.H), C.OW)
}
\begin{document}

\begin{tikzpicture}
    \tkzGetNodes
    \tkzDrawCoordinates[smooth,thick](PA.curve)  \tkzDrawCircle[black,thick](O,W)
    \tkzDrawSegments[thick,-latex](Q,dir)
    \tkzDrawSegments[thick,add=0 and 0.5](P,Q)
    \tkzDrawSegments[thick,dashed,green](O,Q)
    \tkzDrawSegments[thick,green,-latex](O,v)
    \tkzDrawSegments[thick,dash dot,blue](O,H)
    \tkzDrawSegments[thick,blue,-latex](O,u)
    \tkzMarkRightAngle[size=.25,thick](O,H,Q)
    \tkzMarkRightAngle[size=.25,thick](P,Q,dir)
    \draw [magenta,decorate,decoration={brace,mirror,amplitude=10pt}] (O) -- (H) node[midway,below right,xshift=-.15cm,yshift=-.25cm,black] {$h(K,u)$};
    % labels left is your time~
\end{tikzpicture}

\end{document}

image.png

其实还可以使用cascade宏包,不过他没有那么多的微调功能 :-(

由于懒,这里只贴文档的图。

image.png

declare function看文档似乎只能允许一元的输出...

如果重复使用这个坐标就要写很多次了,虽然可以复制粘贴,但是不太优雅
image.png

我一般的做法是\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}

image.png

仅作示范,可以画两次,第二次不要画额外的轴:

\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}

image.png

另外提问要给代码,即使你不能画出双轴,你也应给出绘制单轴的代码。

Claim: ⚠这是一个相当邪修的做法...

我不太确定这是否会造成其他恶劣影响,建议不要使用。

来自我的这个提问

\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}

image.png

Notes: 永远不要在LaTeX里用$$...$$,使用\[...\]。详见这里

Claim:以下只记录我的尝试过程,仅供参考

image.png

Step1

image.png

Step2

image.png

Step3

image.png

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

Step4

image.png

\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}

image.png

术业有专攻,应该找找建筑设计行业的「最佳实践」。

image.png

试了一下现有的宏包, 都相去甚远, 有没有什么好的宏包推荐一下呢?

从代码的注释里我只看到了纯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}

image.png

这个模板只有一些文件名不匹配的小问题,自行修改即可。

https://github.com/fylimas/nsfc/issues/73

也许是精度误差(?)

\documentclass[tikz]{standalone}
\begin{document}
    \begin{tikzpicture}
        \node {\fpeval{tand(45)} v.s. \pgfmathparse{tan(45)}\pgfmathresult};
    \end{tikzpicture}
\end{document}        

image.png

希望在书签里能显示出subsubsection

默认情况下就能显示出subsubsection...请展示你「不能体现出subsubsection书签」的具体截图。

\documentclass[fontset=fandol]{ctexart}
\usepackage{hyperref}
\begin{document}
\section{单词}
\subsection{词汇}
\subsubsection{二级词汇}
\end{document}

image.png

并且把\words{...}中的单词放入书签显示,与subsectionsubsubsection同一层次.

我没有这个字体,字体问题显然与是不是在书签显示,是不是同一层次无关。

image.png

加上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}

image.png

另外,我不觉得单词应该与\subsection或者\subsubsectionlevel.

发布
问题