Sagittarius Rover
Sagittarius Rover
我要成为Typst糕手/(ㄒoㄒ)/~~

注册于 3年前

回答
402
文章
0
关注者
15

你有任何想法或者做过任何尝试吗?如果有,贴上代码是更好的。

最好不要问「do-it-for-me」类型的问题。

也许可以用表格,然后隐去部分垂直线(?)

P.S.我不太明白为什么此处的水平横线是断开的(?)

image.png


太痛苦了

主要同幂次项要对齐比较麻烦。

Claim:我只是为了展示tabularray是多么好评如潮

花了我大约50分钟进行微调...

\documentclass{article}
\usepackage{libertinus-otf}
\usepackage{lipsum}
\usepackage[showframe]{geometry}
\usepackage{tabularray}
% https://tex.stackexchange.com/a/659657/322482

\begin{document}
\lipsum[1][1-5]

\noindent
\begin{tblr}{
    % hlines, 
    % vlines,
    stretch = 2,
    colspec = {X[r]*{14}{Q[c]}X[l]},
    leftsep = 1pt,rightsep = 1pt,
    cells = {mode = dmath},
    vline{2,8,16} = {2}{2-Z}{},
    hline{4} = {2}{2-Y}{},
    hline{6} = {2}{2-7,11-Y}{},
    hline{8} = {2}{11-Y}{},
    column{1,2,7,8,Y,Z} = {leftsep=6pt,rightsep=6pt},
}
 & \SetCell[c=6]{c} g(x) &&&&&&\SetCell[c=8]{c} f(x) & \\
h_2(x)=-\frac{1}{2}+\frac{1}{4} & x^3&+&x^2&-&x&-1&  x^4&+&x^3&-3&x^2&-4&x&-1 & x=h_1(x) \\
 & x^3&+\frac{3}{2}&x^2&+\frac{1}{2}&x& & x^4&+&x^3&-&x^2&-&x& & \\
 &  & - \frac{1}{2} & x^2&-\frac{3}{2}&x&-1  &\SetCell[c=3]{r} r_1(x)=&&&-2&x^2&-3&x&-1 &\frac{8}{3}x+\frac{4}{3}=h_3(x) \\
 &  & - \frac{1}{2} & x^2&-\frac{3}{4}&x&-\frac{1}{4} & &&&-2&x^2&-2&x& & \\
 &  \SetCell[c=3]{r} r_2(x)=&& & -\frac{3}{4}&x&-\frac{3}{4} & &&&&&-&x&-1 & \\
 &  & &  &&& & &&&&&-&x&-1 & \\
 &  & &  &&& & &&&&&&&0 & \\
\end{tblr}

\lipsum[1][1-5]

\end{document}

但其实也有一些运算符之间对齐的细节并不够完美,有强迫症的可以在现有的16列上进一步增加关于「+/-」的对齐点位....

这将得到:

image.png

顺便期待一下tikz-matrix的处理方案...

难点就在于:

aligned 可以,不过对齐比较困难,matrix 内不支持 & 对齐。直接用 \nodeforeach 工作量也不小,主要同幂次项要对齐比较麻烦。

可以在y轴方向上缩放一点,让数字字符拉高/低一点
可以在x轴方向上缩放一点,让数字字符拉宽/瘦一点,以上这是两位数字的情况
当三(多)位数字时,在x轴方向上,数字字符可以再瘦一点,在y轴方向上,与两位数字的情况保持一致

其中「三(多)位数字」要「在y轴方向上,与两位数字的情况保持一致」,这样「2」似乎就会被拉长得的又高又瘦(?)个人觉得略显奇怪...

没完全解决上面的需求

如果只是要调大小的话,也许可以用charshrink来改善「222文字太小」的问题:

image.png

\documentclass{ctexart}
\usepackage{tikz}
\usepackage{circledtext}
\newcommand*{\mysingle}[1]{\circledtext[charshrink=.8]{#1}}
\newcommand*{\mydouble}[1]{\circledtext[charshrink=.85]{#1}}
\newcommand*{\mytriple}[1]{\circledtext[charshrink=.92]{#1}}

\begin{document}
\circledtext{2}\circledtext{22}\circledtext{222}

\tikz{\node[scale=5] {\circledtext{2}\circledtext{22}\circledtext{222}};}

\mysingle{2}\mydouble{22}\mytriple{222}

\tikz{\node[scale=5] {\mysingle{2}\mydouble{22}\mytriple{222}};}

\end{document}

image.png

side-notes:

  • 不建议用pdflatex编译ctexart
  • 若使用xelua,则无需显式写出UTF8,早已是默认值

感谢@u19850 鱼老师...
可以考虑用下面的方式实现将三个命令封装为一个...

image.png

如有可能,请做一些补充说明让这个问题变得更完整,清晰。

另外,真的要自定义新的样式吗?感觉这个工作量跟重写半个circuitikz包差不多大...如果只是新增某个「元件」符号感觉还相对好一点....

这样也许可以避免手动指定xshift=<dim>?

image.png

\documentclass{article}
\usepackage[margin=.8in,centering]{geometry}
\usepackage{showframe,lipsum,tikz,tkz-euclide}
\newcommand*{\inserttkz}[1][]{%
    \begin{tikzpicture}
    \tkzDefPoint(0,0){A}
    \tkzDefPoint(2.5,0){B}
    \tkzDefPoint(1.5,2){C}
    \tkzDrawPolygon[#1](A,B,C)
    \tkzLabelPoints(A,B,C)
    \end{tikzpicture}%
}
\begin{document}
\lipsum[1][1-3]

\fbox{
\begin{tikzpicture}[node distance=.5cm]
  \node (O) {\inserttkz};
  \node[right=of O] (O1) {\inserttkz[blue]};
  \node[right=of O1] (O2) {\inserttkz[magenta]};
  \node[right=of O2] (O3) {\inserttkz[olive]};
\end{tikzpicture}
}

\lipsum[1][1-3]

\end{document}

image.png

上面是这几天遇到的一个压轴题,请教大家怎么绘制。

其实也还是和tkz-euclide有些关系的

Code

先上完整代码:

\documentclass[border=3pt]{standalone}
\usepackage{libertine}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}[scale=1.5,thick,line cap=rounded]
    \tkzDefPoints{-1/0/B,1/0/C,0/sqrt(3)/A}
    \tkzDefPointWith[linear,K=.35](A,B)\tkzGetPoint{D}
    \tkzDefPointWith[linear,K=.35](C,A)\tkzGetPoint{E}
    \tkzInterLL(D,C)(B,E) \tkzGetPoint{F}
    \tkzDrawPolygon(A,B,C)
    \tkzDrawSegments(C,D B,E)
    \tkzLabelPoints[left](A,B,D)
    \tkzLabelPoints[right](C,E)
    \tkzLabelPoints[below](F)
    \node at (0,-.5) {Figure 1};
    \begin{scope}[xshift=3cm]
        \tkzDefPoints{-1/0/B,1/0/C,0/sqrt(3)/A}
        \tkzDefPointWith[linear,K=.35](A,B)\tkzGetPoint{D}
        \tkzDefPointWith[linear,K=.35](C,A)\tkzGetPoint{E}
        \tkzInterLL(D,C)(B,E) \tkzGetPoint{F}
        \tkzDrawPolygon(A,B,C)
        \tkzDrawSegments(C,D B,E)
        \tkzLabelPoints[left](A,B,D)
        \tkzLabelPoints[right](C,E)
        \tkzLabelPoints[below](F)
        %%%%%%%%%%%%%%%%%%%%
        \tkzDefPointBy[projection=onto C--D](B) \tkzGetPoint{G}
        \tkzDrawSegments(B,G A,G)
        \tkzLabelPoints[right](G)
        \node at (0,-.5) {Figure 2};
    \end{scope}
    \begin{scope}[xshift=6cm]
        \tkzDefPoints{-1/0/B,1/0/C,0/sqrt(3)/A,0/0/H,0/-0.2/l}
        \tkzDrawLine(A,H)
        \tkzDrawPolygon(A,B,C)
        \tkzLabelPoints[right](l)
        %%%%%%%%%%%%%%%%%%%%
        \tkzDefPointWith[linear,K=.3](A,H)\tkzGetPoint{M}
        %%%%%%%%%%%%%%%%%%%%
        \tkzDefTriangle[equilateral](M,C) 
        \tkzGetPoint{N}
        \tkzDrawSegments(B,N A,N)
        \tkzDrawPolygon(C,M,N)
        \tkzLabelPoints[below left](B,H)
        \tkzLabelPoints[below right](C)
        \tkzLabelPoints[left=-3pt](M)
        \tkzLabelPoints[right=-2pt](N)
        \tkzLabelPoints[above left](A)
        \node at (0,-.5) {Figure 3};
    \end{scope}
\end{tikzpicture}
\end{document}

image.png

大致思路

图一:基本问题点在于确定D和E的位置,在文档中找到:

image.png

image.png

所以核心代码是:

\tkzDefPointWith[linear,K=.35](A,B)\tkzGetPoint{D}
\tkzDefPointWith[linear,K=.35](C,A)\tkzGetPoint{E}

这里的K=0.35是可供调整的参数,我不懂初中几何,算不出来...算得出来准确比例直接写会更准确...

至于求交点,在之前的回答里也已经用过了:

\tkzInterLL(D,C)(B,E) \tkzGetPoint{F}

图二:基本难点在于「根据B向CD作垂线」

之前的问题也介绍过了,有projection方法:

image.png

\tkzDefPointBy[projection=onto C--D](B) 
\tkzGetPoint{G}

图三:难点在于「根据CM作等边三角形」

但其实你用了tkz-euclide也不难....熟知等边三角形的英文为equilateral,在文档中搜索即可:

image.png

\tkzDefTriangle[equilateral](M,C) 
\tkzGetPoint{N}

P.S.1 如果没有@u26254 老师的回答,我是万万不会想到用scope的(哭)

P.S.2 最好不要不做任何尝试就提问,单独画每一个图都不算难....

很有趣的问题...

不知是否如此?

\documentclass[fontset=fandol]{ctexart}
\usepackage[scale=.85,centering,showframe]{geometry}
% https://tex.stackexchange.com/a/231860/322482
\newcounter{mypara}
\AtBeginDocument{\everypar{\refstepcounter{mypara}}}
\newcounter{noteinpar}[mypara]
\NewDocumentCommand{\noteinpar}{ m m }{%
    \refstepcounter{noteinpar}%
    \textbf{#1}\,\ignorespaces%
    % ${}^{\refstepcounter{noteinpar}\thenoteinpar}$%
    % \textsuperscript{\thenoteinpar}%
    \textsuperscript{\arabic{noteinpar}}%
    {\fangsong(#2)}%
}
\begin{document}

    劳仑衣\noteinpar{普}{桑},认至将指点效\noteinpar{则}{机},最你\noteinpar{更}{枝}。想极整月正进好志次回总般,段然取向使张规军证回,世市总李率英茄持伴。用阶千样响领交出,器程办管据家元写,名其直金团。化达书据始价算每百青,金低给天济办作照明,取路豆学丽适市确。

    如提单各样备再成农\noteinpar{各}{政},设头律走克美技\noteinpar{说}{没},体交才路此\noteinpar{在}{杠}。响育油命转处他住有,一须通给对非交矿今该,花象更面据压来。与花断第然调,很处己队音,程承明邮。常系单要外史按机速引也书,个此少管品务美直管战,子大标蠢主盯写族般本。农现离门亲事以响规,局观先示从开示,动和导便命复机李,办队呆等需杯。见何细线名必子适取米制近,内信时型系节新候节好当我,队农否志杏空适花。又我具料划每地,对算由那基高放,育天孝。派则指细流金义月无采列,走压看计和眼提问接,作半极水红素支花。果都济素各半走,意红接器长标,等杏近乱共。层题提万任号,信来查段格,农张雨。省着素科程建持色被什,所界走置派农难取眼,并细杆至志本。

\end{document}

image.png

应该善用本站的搜索功能

...

既然你的问题是:

请问除了用raisebox使文本和图片垂直居中外,还有其它方法吗?

自行学习总结吧...

P.S.最好把效果图以「图片」形式贴上去而不是仅以「.PDF」的形式,可方便别人直接在网页上查看。

maybe related:

矛盾点在于:

  • \left\{\right.」要被视为一个整体
  • equation x」与「a,b,c」要被视为两个(列)部分

不是很优雅的做法,并没有解决上面的矛盾,借助了tag...

\documentclass[12pt]{ctexart}
\usepackage{showframe}
\usepackage{amsmath,amsfonts}
\usepackage{empheq}
\usepackage{lipsum}
\usepackage{mathtools}
\begin{document}
balabala
\begin{equation}
a^2+b^2=c^2
\end{equation}

\lipsum[2]
\newtagform{myempty}{}{}
\usetagform{myempty}
\begin{empheq}[left=\empheqlbrace]{align}
a^2+b^2=c^2, \tag{a} \\
a^2+b^2=c^2, \tag{b} \\
a^2+b^2=c^2, \tag{c}
\end{empheq}
\usetagform{default}%

\lipsum[2]
\begin{equation}
a^2+b^2=c^2
\end{equation}

\end{document} 

或者更优雅一点写成:

\documentclass[12pt]{ctexart}
\usepackage{showframe}
\usepackage{amsmath,amsfonts}
\usepackage{empheq}
\usepackage{lipsum}
\usepackage{mathtools}
\newtagform{myempty}{}{}
\AddToHook{env/empheq/before}{\usetagform{myempty}}
\AddToHook{env/empheq/after}{\usetagform{default}}
\begin{document}
balabala
\begin{equation}
a^2+b^2=c^2
\end{equation}

\lipsum[2]
\begin{empheq}[left=\empheqlbrace]{align}
a^2+b^2=c^2, \tag{a} \\
a^2+b^2=c^2, \tag{b} \\
a^2+b^2=c^2, \tag{c}
\end{empheq}

\lipsum[2]
\begin{equation}
a^2+b^2=c^2
\end{equation}

\end{document} 

image.png

强烈建议你接着蹲其他回答...

What is graypara ?

请提供一份能体现你问题的完整代码。

「完整」指的是从\documentclass开始到\end{document}结束


就是使用之后所有段都没有了缩进

源代码

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{lipsum}
\newtcolorbox{graypara}{
  colback=gray!20,
  colframe=white,
  boxrule=0pt,
  left=5pt, right=5pt,
  top=3pt, bottom=3pt,
  arc=2pt,
  before=\par\noindent,
  after=\par\noindent
}
\begin{document}%

\lipsum[2]

\begin{graypara}%
    \noindent hour = int(input('Please enter the current hour from 0 to 23: '))

    \noindent if hour < 12:

    \hangindent=4em
    print('Good morning!')

    print('Have a nice day.')

    \noindent elif hour < 18:

    print('Good afternoon!')

    \noindent else:

    print('Good evening!')

    \noindent print('Have a good night.')
\end{graypara}% %注意这里后面的空行

\lipsum[2]
\end{document}

这将得到:

image.png

其实是有缩进的。


一些探索

你在设置中写到:

before=\par\noindent,
after=\par\noindent,

前者可以让你的整个盒子不缩进,而后者直接让你的盒子后的下一段不缩进(如果你不用空行表示新的一段的话)...

另外,你不需要写那么多的\noindent,似乎也不应该写\hangindent=4em,另外,如果要实现「代码盒子」,你可以看一下文档里的tcblistings环境,最好使用等宽字体。

我不知道你的最终目标是什么(你可以做补充),但我如果是我的话,我会修改成:

注意tcblistings中的代码会与你源代码中的缩进保持一致

\documentclass{article}
\usepackage{showframe}
\usepackage{tcolorbox}
\tcbuselibrary{listings}
\usepackage{lipsum}
\newtcblisting{graypara}{
  listing only,
  colback=gray!20,
  colframe=white,
  boxrule=0pt,arc=2pt,
  left=5pt, right=5pt,
  top=3pt, bottom=3pt,
  before=\par\noindent,
  after=\par,
}
\begin{document}%

\lipsum[2]
% 注意tcblistings中的代码会与你源代码中的缩进保持一致

\begin{graypara}
hour = int(input('Please enter the current hour from 0 to 23: '))
if hour < 12:
    print('Good morning!')
    print('Have a nice day.')
elif hour < 18:
    print('Good afternoon!')
else:
    print('Good evening!')
    print('Have a good night.')
\end{graypara}

\lipsum[2]

\lipsum[2]

\end{document}

image.png

我希望用 pgfkeys 构造一个绘图命令:\mydraw,为了简化问题,它只带一个键值对:color = <line color>, 但我希望它还允许其他的 "\draw 的参数" (键值对)加入。以下是它的定义过程:

总觉得上面的实现是为了用pgfkeys而用,而从整体思路来看有些许绕...

我个人觉得更直接的方式是:

\documentclass[tikz,border=5pt]{standalone}
\tikzset{
  mycmd/.style={
    color=black,#1
  }
}
\newcommand{\mydraw}[1][]{%
  \draw[mycmd={#1}] (0,0) -- (2,0); 
}
\begin{document}
\begin{tikzpicture}
  \mydraw[color=blue, line width=1mm]
  \begin{scope}[yshift=-0.5cm]
    \mydraw[line width=2pt, ->, rounded corners, magenta]
  \end{scope}
  \begin{scope}[yshift=-1cm]
    \mydraw[<-latex,semithick]
  \end{scope}
\end{tikzpicture}
\end{document}

或者展开\tikzset的定义:

\documentclass[tikz,border=5pt]{standalone}
\pgfkeys{
    tikz/.cd,
    mycmd/.style={
      color=black,#1
    }
}
\newcommand{\mydraw}[1][]{%
  \draw[mycmd={#1}] (0,0) -- (2,0); 
}
\begin{document}
\begin{tikzpicture}
  \mydraw[color=blue, line width=1mm]
  \begin{scope}[yshift=-0.5cm]
    \mydraw[line width=2pt, ->, rounded corners, magenta]
  \end{scope}
  \begin{scope}[yshift=-1cm]
    \mydraw[<-latex,semithick]
  \end{scope}
\end{tikzpicture}
\end{document}

image.png

先问要不要设置成与此相同的样式?

我个人认为是不需要的。

https://tex.stackexchange.com/questions/534216/when-using-elsarticle-cls-how-to-make-each-bibliography-item-a-clickable-hyperl#comment1351153_534216

If Elsevier wanted a particular format, surely their document class should implement it. Depending on their workflow it may actually be counterproductive to introduce the (unquestionably) required additional markup commands for the links as they may throw off tools that parse the TeX source.

慕子老师有过这样一个评论(但我一时找不到了)

文章投稿时的样式和文章发表出来的样式不同是很正常的,按照「模板的说明文档」使用即可

啸行老师也提到过

你别学 elsevier 家正式刊登的论文……

综上,这个需求对于「投稿者」来说是不必须的。

我假定你是在使用 CTAN 上最新的「cas-dc」文档类来实现类似的排版。其中指出:

image.png

其模板自带的示例的效果也不需要「将超链接设置为蓝色的可点击形式」

image.png

因此该问题基本可以视为"伪需求"...

请注意:

elegantbook-cn 默认的后端是biber而不是bibtex

image.png

所以你需要的编译命令是:

xelatex-biber-xelatex-xelatex (不是bibtex)

或者

latexmk -pdfxe


也许可行的方法:
1.打开终端
2.输入latexmk -C回车
3.输入latexmk -pdfxe mathmode回车

理论上不应该有问题...(只要你的文件没大问题....)


如果你对上面的知识感到困惑,十有八九是没有仔细阅读过lshort-zh-cn6.1节....

建议你仔细阅读,区分好下面两套不同「参考文献」方案的区别:

  • bibtex
  • biblatexbiber

再结合上面的文档信息做理解。


TL;DR

如果用默认的bibend=biber,那么你需要xe-biber-xe-xe

如果你用bibend=bibtex,那么你需要xe-bibtex-xe-xe(但后者的功能会受到一定的限制...)

maybe related: https://tex.stackexchange.com/questions/142296/tikz-tree-fork-down-edge-labels

但我看不太懂....


tikz-ext库中有很方便的<spec>:|-|-|-

image.png

\documentclass[border=2pt,tikz]{standalone}
\usetikzlibrary{trees,ext.paths.ortho}
\tikzset{
    every node/.style={draw,inner sep=2pt},
    level/.style={level distance=1.5cm},
    level 1/.style={sibling distance=4.5cm},
    level 2/.style={sibling distance=2cm}
}
\begin{document}
\begin{tikzpicture}
    \node (A) {A} 
    [edge from parent fork down]
    child {node (A1) {A.1}
           child {node {A.1.1}}
           child {node {A.1.2}}
          }
    child {node {A.2}
           child {node {A.2.1}}
           child {node {A.2.2}}
          }
    ;
    \path[magenta,draw] (A1.north) |-| (A.south) 
        node[pos=.25] {.25}
        node[pos=.5] {.5}
        node[pos=.75] {.75}
        node[pos=.875] {.875}
        coordinate[pos=.875] (P)
        ;
    \node[inner sep=0pt,circle,pin=above right:P] at (P) {};
\end{tikzpicture}
\end{document}

image.png

但这不一定是最佳实践....

发布
问题