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

注册于 3年前

回答
389
文章
0
关注者
15

请注意:

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字体是该怎么用啊

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

这是一个在ai需求上修改的回答

\documentclass{standalone}
\usepackage{tkz-base}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}[scale=1.2]
% ===== 1. 绘制平面直角坐标系 =====
\tkzInit[xmin=-3, xmax=5, ymin=-3, ymax=2]
\tkzGrid[color=gray!30, line width=0.5pt]
\tkzLabelX[orig=false, below=8pt]        
\tkzLabelY[orig=false, left=8pt]
\tkzDrawXY[noticks, >=latex]    
% ===== 2. 定义并标记点P(1,1)、点A(0,-2) =====
\tkzDefPoints{1/1/P, 0/-2/A, 0/0/O} 
\tkzDrawPoints[fill=blue, size=4](P,A)  
\tkzLabelPoints[above right](P)  
\tkzLabelPoints[below left](A,O)    

% ===== 3. 在x轴正半轴找点B满足 PA = PB =====

\tkzDefPoints{0/0/O,4/0/X}
\tkzInterLC(O,X)(P,A) % 圆与x轴的交点
\tkzGetPoints{C}{B}   % 获取两个交点(取正半轴的点)
\tkzDrawPoint[fill=red, size=4](B) 
\tkzLabelPoint[above](B){$B$} 

% ===== 4. 连接线段并添加标注 =====
\tkzDrawSegments[thick](P,A P,B)       

\end{tikzpicture}
\end{document}

image.png

我强烈建议你在文档上花时间,AI只是提供补全和辅助

享受看着文档一步步学东西的乐趣,而不是全部丢进AI,得到一份(可能)有多处暗病的回答,当一份代码里有3~5个bug,你修起来的时间成本并不比自己读文档低....

还有一些标点、标线段长一类的细节

实现留做习题、读文档并不难

这只是一个告诉你「代码为何报错」的post..

AI只是起补全效果/提供思路,不能完全用来搭建框架,务必在文档里做验证并自行学习,切忌在对输出的代码完全不懂的前提下使用AI的代码。

debug步骤一:

Undefined control sequence. ^^I^^I\tkzDrawXY

你需要在tkz-euclide中搜索.....

你会发现仅有\tkzDrawX或者\tkzDrawY

事实上\tkzDrawXY这个命令需要tkz-base,加上\usepackage{tkz-base}之后:

\documentclass{standalone}
\usepackage{tkz-base}
\usepackage{tkz-euclide}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=1.2]

% ===== 1. 绘制平面直角坐标系 =====
\tkzInit[xmin=-3, xmax=3, ymin=-3, ymax=2]  % 设置坐标范围
\tkzGrid[color=gray!30, line width=0.5pt]     % 添加浅灰色网格
\tkzDrawXY[noticks, >=latex]                 % 绘制坐标轴(无刻度,箭头样式)
\tkzLabelX[orig=false, below=8pt]           % 标注x轴(原点不重复标记)
\tkzLabelY[orig=false, left=8pt]            % 标注y轴

% ===== 2. 定义并标记点P(1,1)、点A(0,-2) =====
\tkzDefPoints{1/1/P, 0/-2/A}                % 定义点P和点A
\tkzDrawPoints[fill=blue, size=4](P,A)       % 绘制蓝色实心点
\tkzLabelPoints[above right](P)             % 标记点P(右上)
\tkzLabelPoints[below left](A)              % 标记点A(左下)

% ===== 3. 在x轴正半轴找点B满足 PA = PB =====
% 原理:B在x轴上且满足PB=PA → B是以P为圆心、PA为半径的圆与x轴的交点
\tkzDefCircle[radius](P,A)                  % 定义以P为圆心、PA为半径的圆
\tkzGetLength{PRad}                         % 获取半径长度
\tkzInterLC[R](tkzPointResult,tkzPointResult)(P,\PRad pt) % 圆与x轴的交点
\tkzGetPoints{B}{C}                         % 获取两个交点(取正半轴的点)
\tkzDrawPoint[fill=red, size=4](B)           % 绘制红色点B
\tkzLabelPoint[above](B){$B$}               % 标记点B

% ===== 4. 连接线段并添加标注 =====
\tkzDrawSegments[thick](P,A P,B)             % 绘制PA和PB(粗实线)
\tkzLabelSegment[above left](P,A){$PA$}      % 标注PA
\tkzLabelSegment[above right](P,B){$PB$}     % 标注PB

% ===== 添加构造辅助标记(可选)=====
\tkzDrawCircle[dashed, red, thin](P,A)       % 红色虚线圆(辅助构造)
\tkzCompasss[color=blue](P,A P,B)            % 标记等距弧线(蓝色)
\node[align=left, below] at (0,-2.5) { 
    $PA = PB$,$B$ 是圆 $P(PA)$ 与 $x$ 轴正半轴的交点
};

\end{tikzpicture}
\end{document}

报错信息变为:

! Package pgfkeys Error: I do not know the key '/tkzcircle/radius' and I am goi
ng to ignore it. Perhaps you misspelled it.

See the pgfkeys package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.23 \tkzDefCircle[radius](P,A)
                                                 % 定义以P为圆心、PA...

?

这说明\tkzDefCircle不按照语法乱写呗...

debug步骤二:

image.png

显然,应该用R而不是radius,需要参考这个例子,第二个参数应该传入半径而不是圆周上的点....

image.png

\documentclass{standalone}
\usepackage{tkz-base}
\usepackage{tkz-euclide}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=1.2]

% ===== 1. 绘制平面直角坐标系 =====
\tkzInit[xmin=-3, xmax=3, ymin=-3, ymax=2]  % 设置坐标范围
\tkzGrid[color=gray!30, line width=0.5pt]     % 添加浅灰色网格
\tkzDrawXY[noticks, >=latex]                 % 绘制坐标轴(无刻度,箭头样式)
\tkzLabelX[orig=false, below=8pt]           % 标注x轴(原点不重复标记)
\tkzLabelY[orig=false, left=8pt]            % 标注y轴

% ===== 2. 定义并标记点P(1,1)、点A(0,-2) =====
\tkzDefPoints{1/1/P, 0/-2/A}                % 定义点P和点A
\tkzDrawPoints[fill=blue, size=4](P,A)       % 绘制蓝色实心点
\tkzLabelPoints[above right](P)             % 标记点P(右上)
\tkzLabelPoints[below left](A)              % 标记点A(左下)

% ===== 3. 在x轴正半轴找点B满足 PA = PB =====
% 原理:B在x轴上且满足PB=PA → B是以P为圆心、PA为半径的圆与x轴的交点


% \tkzDefCircle[radius](P,A)%错误!                  % 定义以P为圆心、PA为半径的圆
\tkzCalcLength(P,A) 
\tkzGetLength{rPA} 
\tkzDefCircle[R](P,\rPA)
% \tkzGetLength{PRad}                         % 获取半径长度
\tkzInterLC[R](tkzPointResult,tkzPointResult)(P,\PRad pt) % 圆与x轴的交点
\tkzGetPoints{B}{C}                         % 获取两个交点(取正半轴的点)
\tkzDrawPoint[fill=red, size=4](B)           % 绘制红色点B
\tkzLabelPoint[above](B){$B$}               % 标记点B

% ===== 4. 连接线段并添加标注 =====
\tkzDrawSegments[thick](P,A P,B)             % 绘制PA和PB(粗实线)
\tkzLabelSegment[above left](P,A){$PA$}      % 标注PA
\tkzLabelSegment[above right](P,B){$PB$}     % 标注PB

% ===== 添加构造辅助标记(可选)=====
\tkzDrawCircle[dashed, red, thin](P,A)       % 红色虚线圆(辅助构造)
\tkzCompasss[color=blue](P,A P,B)            % 标记等距弧线(蓝色)
\node[align=left, below] at (0,-2.5) { 
    $PA = PB$,$B$ 是圆 $P(PA)$ 与 $x$ 轴正半轴的交点
};

\end{tikzpicture}
\end{document}

这同样将报错:

! Undefined control sequence.
<argument> \PRad
                 pt cm
l.30 ...tkzPointResult,tkzPointResult)(P,\PRad pt)
                                                   % 圆与x轴的交点
?

这又说明第30行:

\tkzInterLC[R](tkzPointResult,tkzPointResult)(P,\PRad pt) % 圆与x轴的交点

写的一窍不通,垃圾AI.....

debug步骤三:

稍微想了一下:

\tkzDefCircle[radius](P,A)                  % 定义以P为圆心、PA为半径的圆
\tkzGetLength{PRad}                         % 获取半径长度
\tkzInterLC[R](tkzPointResult,tkzPointResult)(P,\PRad pt) % 圆与x轴的交点

这部分可以优化

\tkzDefPoints{0/0/O,4/0/X}
\tkzInterLC(O,X)(P,A) % 圆与x轴的交点

换句话说

\documentclass{standalone}
\usepackage{ctex}
\usepackage{tkz-base}
\usepackage{tkz-euclide}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=1.2]

% ===== 1. 绘制平面直角坐标系 =====
\tkzInit[xmin=-3, xmax=3, ymin=-3, ymax=2]  % 设置坐标范围
\tkzGrid[color=gray!30, line width=0.5pt]     % 添加浅灰色网格
\tkzDrawXY[noticks, >=latex]                 % 绘制坐标轴(无刻度,箭头样式)
\tkzLabelX[orig=false, below=8pt]           % 标注x轴(原点不重复标记)
\tkzLabelY[orig=false, left=8pt]            % 标注y轴

% ===== 2. 定义并标记点P(1,1)、点A(0,-2) =====
\tkzDefPoints{1/1/P, 0/-2/A}                % 定义点P和点A
\tkzDrawPoints[fill=blue, size=4](P,A)       % 绘制蓝色实心点
\tkzLabelPoints[above right](P)             % 标记点P(右上)
\tkzLabelPoints[below left](A)              % 标记点A(左下)

% ===== 3. 在x轴正半轴找点B满足 PA = PB =====
% 原理:B在x轴上且满足PB=PA → B是以P为圆心、PA为半径的圆与x轴的交点

\tkzDefPoints{0/0/O,4/0/X}
\tkzInterLC(O,X)(P,A) % 圆与x轴的交点
\tkzGetPoints{B}{C}                         % 获取两个交点(取正半轴的点)
\tkzDrawPoint[fill=red, size=4](B)           % 绘制红色点B
\tkzLabelPoint[above](B){$B$}               % 标记点B

% ===== 4. 连接线段并添加标注 =====
\tkzDrawSegments[thick](P,A P,B)             % 绘制PA和PB(粗实线)
\tkzLabelSegment[above left](P,A){$PA$}      % 标注PA
\tkzLabelSegment[above right](P,B){$PB$}     % 标注PB

% ===== 添加构造辅助标记(可选)=====
\tkzDrawCircle[dashed, red, thin](P,A)       % 红色虚线圆(辅助构造)
\tkzCompasss[color=blue](P,A P,B)            % 标记等距弧线(蓝色)
\node[align=left, below] at (0,-2.5) { 
    $PA = PB$,$B$ 是圆 $P(PA)$ 与 $x$ 轴正半轴的交点
};

\end{tikzpicture}
\end{document}

不报错了...但好像和OP的目标也有差距...

image.png

其实非常简单,只要把合并单元格挪到下面一格就行了\multirow支持反向合并
% !tex xelatex
\documentclass[a4paper]{ctexart}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{array}
\usepackage{multirow}
\usepackage{colortbl} % 必须包含的包
\usepackage{xcolor}
\usepackage{graphicx}
\definecolor{lightblue}{rgb}{0.85,0.95,1}
\definecolor{lightyellow}{rgb}{1,1,0.85}

\begin{document}
\pagestyle{empty}
\centering

{\LARGE\bfseries 九九乘法口诀表}\\[1cm]

% 主乘法表
\begin{minipage}{0.9\textwidth}
\centering
\setlength{\tabcolsep}{3mm} % 列间距
\renewcommand{\arraystretch}{1.5} % 行高
\begin{tabular}{|>{\columncolor{lightblue}}c|*{9}{>{\centering\arraybackslash}m{1.2cm}|}}
\hline
\rowcolor{lightyellow}
& 
\multicolumn{9}{c|}{\textcolor{red}{被乘数}} \\
\cline{2-10}
\rowcolor{lightblue}
\cellcolor{lightyellow}
\multirow{-2}{*}{\textcolor{red}{乘数}}
& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
\hline
1 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
\hline
2 & 2 & 4 & 6 & 8 & 10 & 12 & 14 & 16 & 18 \\
\hline
3 & 3 & 6 & 9 & 12 & 15 & 18 & 21 & 24 & 27 \\
\hline
4 & 4 & 8 & 12 & 16 & 20 & 24 & 28 & 32 & 36 \\
\hline
5 & 5 & 10 & 15 & 20 & 25 & 30 & 35 & 40 & 45 \\
\hline
6 & 6 & 12 & 18 & 24 & 30 & 36 & 42 & 48 & 54 \\
\hline
7 & 7 & 14 & 21 & 28 & 35 & 42 & 49 & 56 & 63 \\
\hline
8 & 8 & 16 & 24 & 32 & 40 & 48 & 56 & 64 & 72 \\
\hline
9 & 9 & 18 & 27 & 36 & 45 & 54 & 63 & 72 & 81 \\
\hline
\end{tabular}
\end{minipage}

\end{document}

image.png

另外,这个需求显然有基于循环的方案,可参考这个链接

一个基于tkz-euclide的可能方案,有大量瑕疵:

  • "质心"可以最好地近似「N个点的"最小覆盖圆"的圆心」吗?
  • 图中使用\tkzAutoLabelPoints来调整dist也并不完美,点A,B,C,F偏远;点DE偏近
  • \tkzDefBarycentricPoint(A=1,B=1,C=1,D=1,E=1,F=1)语法冗杂,而\tkzCentroid(A,B,C)仅支持三个点
  • 暂时没有做封装...
\documentclass[tikz,border=5mm]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
  \tkzDefPoints{-1/-1/A, 1/-2/B, 3/0/C, 2/4/D, 0/5/E,-3/2/F}  
  \tkzDrawPolygons[thick](A,...,F)
% \tkzLabelPoints(A,...,F) % No!
% \tkzCentroid(A,B,C) %怎么只支持三个点呢..真可惜
\tkzDefBarycentricPoint(A=1,B=1,C=1,D=1,E=1,F=1)
\tkzGetPoint{centroid}
\tkzDrawPoint(centroid)
\tkzAutoLabelPoints[center = centroid,dist= .12](A,...,F)
\end{tikzpicture}
\end{document}

image.png

抛砖引玉了~ 期待@u817 老师提供更general方案的补充


Edited:

使用\pathpos..对位置的控制相对好一些了,但是却不能很好的融入tkz-euclide的框架里...

这里的各个label和点的距离是「路径(centeroid--\x)的长度*0.1」,因为不好找到精准的最小覆盖圆(因为多点情况下这不存在),长度不相等,这是利用pos的瑕疵...

\documentclass[tikz,border=5mm]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
  \tkzDefPoints{-1/-1/A, 1/-2/B, 3/0/C, 2/4/D, 0/5/E,-3/2/F}  
  \tkzDrawPolygons[thick](A,...,F)
% \tkzLabelPoints(A,...,F) % No!
% \tkzCentroid(A,B,C) %怎么只支持三个点呢..真可惜
\tkzDefBarycentricPoint(A=1,B=1,C=1,D=1,E=1,F=1)
\tkzGetPoint{centroid}
\tkzDrawPoint(centroid)
% \tkzAutoLabelPoints[center = centroid,dist= .12](A,...,F)
\foreach \x in {A,...,F}{
    \path (centroid) -- (\x) node [text=magenta,pos=1.1] {\x};
}
\end{tikzpicture}
\end{document}

image.png

很棒!学以致用!

也许从下面这个例子里可以找到原因:

image.png

name=H意味着得到的垂直实际上名为HaHbHc...

\documentclass[tikz, border=5mm]{standalone}
\usepackage{tkz-euclide}
%\usetkzobj{all} % 解决命令未定义问题 - 加载所有对象类型
\usetikzlibrary{angles, quotes} % 用于绘制角度标记

\begin{document}
    \begin{tikzpicture}[scale=0.8]
        % 定义三个顶点
        \tkzDefPoints{-1.5/0/B, 1.5/0/C, 0/4/A}
        % 定义垂心
        \tkzDefTriangleCenter[ortho](A,B,C)
        \tkzGetPoint{P}
        % 定义三个垂足
        \tkzDefSpcTriangle[ortho,name=P](A,B,C){D,E,F}
        % 画三角形ABC,画三个顶点,连三条高线
        \tkzDrawPolygon[thick][color=blue](A,B,C)
%        \tkzDrawPoints(A,B,C,P)
%        \tkzDrawSegments[thick](A,PD B,PE C,Pc)
        \tkzDrawSegments[thick](A,PD B,PE)
        % 添加标签
        \tkzLabelPoint[above left](P){$P$}
        \tkzLabelPoint[above](A){$A$}
        \tkzLabelPoint[below left](B){$B$}
        \tkzLabelPoint[below right](C){$C$}
        \tkzLabelPoint[below](PD){$D$}
        \tkzLabelPoint[right](PE){$E$}
%        \tkzAutoLabelPoints[center=P](A,B,C)        
    \end{tikzpicture}
\end{document}

image.png


如何debug?

Package pgf Error: No shape named `D' is known. ^^I^^I\tkzLabelPoint[below](D){$D$}
Package pgf Error: No shape named `E' is known. ^^I^^I\tkzLabelPoint[right](E){$E$}

查看报错信息,为什么只有DE找不到,看看这两个点是在\tkzDefSpcTriangle里定义的,回去翻\tkzDefSpcTriangle的文档:

(此事在文档中亦有记载...)

image.png


关于如何精确让AE=BE...

这里的E点如果直接用AE=BE个人觉得会稍显复杂,因为衡量长度似乎稍显代码冗长....

条条大道通罗马...

第一个思路:「高+等腰=等腰直角大概可以想到中垂线」

  • 确定A、B、C
  • 作高AD⊥BC
  • 作AB上的中垂线交AC于E
\documentclass[tikz,border=5mm]{standalone}
\usepackage{tkz-euclide}
\usetikzlibrary{angles}
\begin{document}
    \begin{tikzpicture}[line cap=round,line join=round]
        \tkzDefPoints{-1.5/0/B, 1.5/0/C, 0/4/A}
        \tkzDefPointBy[projection = onto B--C](A)
        \tkzGetPoint{D}

        \tkzDefLine[mediator](A,B)
        \tkzGetPoints{P1}{P2}
        \tkzInterLL(A,C)(P1,P2) 
        \tkzGetPoint{E}

        \tkzInterLL(A,D)(B,E) 
        \tkzGetPoint{P}

        \tkzDrawSegments[thick](A,D B,E)
        \tkzDrawPolygon[semithick](A,B,C)
 
        \tkzLabelPoint[above](A){$A$}
        \tkzLabelPoint[below left](B){$B$}
        \tkzLabelPoint[below right](C){$C$}
        \tkzLabelPoint[below](D){$D$}
        \tkzLabelPoint[right](E){$E$}
    \end{tikzpicture}
\end{document}

image.png

不过这似乎不太直角...

再看看「点A」应该如何定位吧...

嗯,显然∠BAC是45°,对于(-1.5,0) (1.5,0)和(0,4)用余弦定理理论上这个角不是45°,所以要想完全精确最好是不要直接给定ABC的坐标,应该另谋他路来「用最少的点唯一确定这个图形」...


未完待续....

可以直接用pgfplots:

\documentclass[a4paper,border=2pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    axis lines=middle,
    xlabel=$x$,
    ylabel=$y$,
    xmin=-3, xmax=5,
    ymin=-2, ymax=5,
    samples=300,
    smooth,thick,
    grid=major,
    grid style={gray!30},
]
    \addplot[cyan, dashed, domain=-3:5] {abs(x) - 1};
    \addplot[violet, dotted, domain=-3:5] {(x-2)^2};
    \addplot[red, ultra thick, domain=-3:5] {min(abs(x)-1, (x-2)^2)};
\end{axis}
\end{tikzpicture}
\end{document}

image.png

「函数图像」和「平面欧几里得图形」是不太一样的,应该选择最合适的工具。

niceamtrix的方案二:

同样是读文档!!

image.png

\documentclass{article}
\usepackage{libertinus-otf}
\usepackage{nicematrix}
\usepackage{tikz}
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\[
X = 
\begin{pNiceMatrix}[
        create-large-nodes,
        left-margin=7pt,
        right-margin=2pt
    ]
    1 & 0 & 2 & 0 & -3 \\
    0 & 1 & -1 & 0 & -4 \\
    0 & 0 & 0 & 3 & 5 \\
    0 & 0 & 0 & 0 & 0 \\
    \CodeAfter
    \tikz \draw[densely dashed,violet]
    (1|-1) -- (1|-2) -- (2|-2) -- (2|-3) -- (4|-3) -- (4|-4) -- (6|-4)
    ;
\end{pNiceMatrix}
= Y
\]
\lipsum[2]

\end{document}

image.png

nicematrix的方案一:

\documentclass{article}
\usepackage{libertinus-otf}
\usepackage{nicematrix}
\usepackage{tikz}
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\[
X = 
\begin{pNiceMatrix}[extra-margin=7pt,cell-space-limits=.125cm]
1\Block[borders={bottom,left,tikz=densely dashed}]{1-1}{} & 0 & 2 & 0 & -3 \\
0 & 1\Block[borders={bottom,left,tikz=densely dashed}]{1-2}{} & -1 & 0 & -4 \\
0 & 0 & 0 & 3\Block[borders={bottom,left,tikz=densely dashed}]{1-2}{} & 5 \\
0 & 0 & 0 & 0 & 0 \\
\end{pNiceMatrix}
= Y
\]
\lipsum[2]

\end{document}

image.png

发布
问题