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

注册于 3年前

回答
397
文章
0
关注者
15

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

其实也还是和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

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

一个也许可行的方案:

(1)删去WileyNJDv5.cls中的\reserveinserts{28}(这样做是否稳健...我不清楚...)

% Line 356
\usepackage{etex}%
% \reserveinserts{28}% 注释这一行
% included etex package and \reserveinserts{...} to avoid no room for \newinserts, \newcounts or \newskips etc.
\RequirePackage{graphicx,multicol}%
\RequirePackage{multirow}%

(2)根据这个链接,注意到需要特定版本的listings宏包,自行补充到根目录即可,或者如果不需要插入listings...那么断舍离,注释去\usepackage{listings}

% Line 6821
\usepackage{algorithm, algorithmicx, algpseudocode}
% \usepackage{listings}%% 注释这一行
\usepackage{alltt}%

同时注释去wileyNJDv5_AMA.tex中的

% Line 664 
% \begin{lstlisting}[caption={Descriptive caption text},label=DescriptiveLabel, basicstyle=\fontsize{8}{10}\selectfont\ttfamily]
% for i:=maxint to 0 do
% begin
% { do nothing }
% end;
% Write('Case insensitive ');
% WritE('Pascal keywords.');
% \end{lstlisting}

若如此做,在TL2025下使用latexmk -pdfxe wileyNJDv5_AMA.tex编译主文件wileyNJDv5_AMA.tex可以顺利编译得到:

image.png

image.png

image.png

image.png

当然,关于这份模板,一切使用务必严格按照Author-guideline_Wiley.pdf

image.png

基于慕子老师的这个回答,不借助任何已有的轮子(如borderline等),基于subskin可以把整个边框路径视为一个整体,可以有如下的实现:

\documentclass{article}
\usepackage[papersize={15cm, 6cm}, margin=.3in]{geometry}
\usepackage{lipsum}
\usepackage{tcolorbox}
\tcbuselibrary{breakable, skins, theorems}

\tikzset{
  mybox frame/.style={
    tcbcolframe, line width=1.5pt, line cap=round
  }
}

\tcbsubskin{mybox}{empty}{
    frame engine=path,
    enlarge top by=1ex,
    fonttitle=\bfseries\Large\sffamily,
  % make title another tcolorbox, in natual width
  attach boxed title to top left={
        xshift=3em,
        yshift=-\tcboxedtitleheight/2+2pt,
        yshifttext=-\tcboxedtitleheight/2+2pt
    },
  boxed title style={
    skin=empty,
    % frame code={
        % \draw[red] (frame.north west) rectangle (frame.south east);
    % }
  },
  % frame code specific for unbroken boxes
  frame code={
    \draw[mybox frame]
        ([yshift=-2pt]title.west) -| (frame.south west) -| (frame.north east)
        ([yshift=-2pt]title.east) -- ++(3em,0)
        ;
  },
  % frame code for broken boxes
  skin first is subskin of={emptyfirst}{
    frame code={
        \draw[mybox frame]
        ([yshift=-2pt]title.west) -| (frame.south west)
        (frame.south east) -- (frame.north east)
        ([yshift=-2pt]title.east) -- ++(3em,0)
        ;
    }
  },
  skin middle is subskin of={emptymiddle}{
    frame code={
      \draw[mybox frame]
          (frame.north east) -- (frame.south east)
          (frame.north west) -- (frame.south west);
    }
  },
  skin last is subskin of={emptylast}{
    frame code={
      \draw[mybox frame]
          (frame.north east) 
          -- (frame.south east)
          -- (frame.south west) 
          -- (frame.north west);
    }
  }
}

\NewTColorBox[
    auto counter,
    number within=chapter
]{mytcbbox}{O{black}m}{
    breakable,
    skin=mybox,
    colframe=#1,
    coltitle=#1,
    title=#2,
}

\begin{document}
\section{Using subskin, unbroken box}

\begin{mytcbbox}{This is a theorem}
    \lipsum[1][1-5]
\end{mytcbbox}

\section{Using subskin, broken box}

\begin{mytcbbox}[violet]{This is another theorem}
    \lipsum[1-2]
\end{mytcbbox}
\end{document}

image.png

至于\Cref或者\Doubleref的问题,不是本问题的重点,应该开新的提问。

0.作为例子,请用example-image而不是photo/层次分析法图1.jpg

前者在每个安装了TL的电脑上都有,后者只有你有

1.读一下lshort-zh-cn

image.png

默认是t-b-p

2.你可以试着显式写为h:

\documentclass{article}
\usepackage{showframe}
\usepackage{graphicx}
\usepackage{ctex}

\title{层次分析法暑期练习}
\author{qiao xinkai}
\date{\today}

\begin{document}

\maketitle

\section{模型建立}
\subsection{建立系统的递阶层次结构}

\begin{figure}[h]
    \centering
    \includegraphics[width=1.2\textwidth,height=0.9\textwidth]{example-image}
    \caption{图1.1.饲养地选择层次结构图}
    \label{fig:cengci}
\end{figure}
\end{document}

image.png

3.可以试着调一下图片高度

\documentclass{article}
\usepackage{showframe}
\usepackage{graphicx}
\usepackage{ctex}

\title{层次分析法暑期练习}
\author{qiao xinkai}
\date{\today}

\begin{document}

\maketitle

\section{模型建立}
\subsection{建立系统的递阶层次结构}

\begin{figure}[h]
    \centering
    \includegraphics[width=1.2\textwidth,height=.85\textwidth]{example-image}
    \caption{图1.1.饲养地选择层次结构图}
    \label{fig:cengci}
\end{figure}
\end{document}

image.png

但是,我不推荐在「定稿的最后一刻」调整浮动体的位置

LaTeX的一大原则是内容与样式分离,多关注内容,图片位置想在哪里就让他去吧...浮动体总是要随意浮动的...

推荐阅读

P.S. showframe是为了显示页面layout,进一步说明「位置不够」....

在命令行输入:

texdoc mpfonts

这将得到:

mpfonts
Maintained by Daniel Benjamin Miller
January 30, 2020

***

The Computer Modern fonts are available in Type 1 format, but these renditions
are somewhat thin and spindly, and produce much lighter results than the
originals. It is alternatively possible to use METAFONT bitmaps, but this has
its disadvantages in comparison with vector fonts.

These fonts are conversions to Type 3 fonts, done entirely in METAPOST;
they are vector fonts which are a direct conversion from the original METAFONT
files, so they are the design most authentic to the originals.

However, these fonts, because they are PostScript Type 3 fonts, are not
suitable for on-screen reading, and should probably only be used for printing.

In order to produce a document using these fonts, first produce a DVI with
TeX or LaTeX, and then run dvips as follows:

dvips -D 10000 -u +mpfonts.map myfile.dvi

This will output a PostScript file using these fonts. It is recommended to keep
the resolution at 10000 DPI, since this allows for the most accurate glyph
positioning. As the fonts are vector fonts, this will not increase file size
in comparison with lower DPI settings.

***

The following font sets are supported:

* Computer Modern (cm)
* LaTeX fonts (latex-fonts)
* Frege symbols (fge)
* Extra logic symbols (cmll)
* Fraktur (cmfrak)
* AMS fonts (amsfonts)
* IPA (tipa)

Note that the T1 encoding is not directly supported. When using this package,
use the classic OT1 encoding (this is the default encoding, and will be used
unless you choose to change it).

丢进AI:

mpfonts
由 Daniel Benjamin Miller 维护
2020年1月30日

***

Computer Modern 字体虽提供 Type 1 格式,但这些版本略显纤细单薄,输出效果较原版更为轻淡。虽然也可使用 METAFONT 点阵字体,但与矢量字体相比存在固有缺陷。

本套字体通过 METAPOST 完全转换为 Type 3 格式,是从原始 METAFONT 文件直接转换的矢量字体,因此最大程度保留了原版的设计精髓。

需要注意的是,由于采用 PostScript Type 3 格式,这些字体不适合屏幕阅读,建议仅用于印刷场景。

使用步骤:
1. 先用 TeX 或 LaTeX 生成 DVI 文件
2. 执行以下 dvips 命令:`dvips -D 10000 -u +mpfonts.map myfile.dvi`

将生成采用本字体的 PostScript 文件。推荐保持 10000 DPI 分辨率以确保字形定位精确。由于是矢量字体,较高分辨率不会导致文件体积增大。

***

支持以下字体集:
* Computer Modern (cm)
* LaTeX fonts (latex-fonts)
* Frege symbols (fge)
* Extra logic symbols (cmll)
* Fraktur (cmfrak)
* AMS fonts (amsfonts)
* IPA (tipa)

特别说明:本包不直接支持 T1 编码,使用时请采用经典 OT1 编码(此为默认编码,除非手动更改)。

所谓type3字体是该怎么用啊

此事在「使用步骤」中亦有说明....

发布
问题