在 tikzpicture 上排版标题

在 tikzpicture 上排版标题

我想在 上添加标题tikzpicture。在下面的代码中,我在环境内的显示器上添加了标题axis。此环境是多余的,因为我不想在显示器上绘制任何轴。我想axis从我的代码中删除环境。

另外,我希望在标题中将AB(表示点)和\ell(表示线)以粗体显示。使用以下代码时出现错误。

title=An illustration of \boldmath$A$ and $B$\unboldmath \\ being on the same side of \boldmath$\ell$\unboldmath

这是代码。

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}

\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections}


\usepackage{pgfplots}
\pgfplotsset{compat=1.11}


\begin{document}



\begin{tikzpicture}
\begin{axis}[
    title=An illustration of points $A$ and $B$ \\ being on the same side of $\ell$, title style={align=center,font=\bfseries}
    ]
\end{axis}

\coordinate (A) at (0,0);
\draw[fill] (A) circle (1.5pt);
\coordinate (B) at (1.5,2);
\draw[fill] (B) circle (1.5pt);
\draw (A) -- (B);

\coordinate (point_to_label_A) at ($(A)!-7.5pt!(B)$);
\node at (point_to_label_A){$A$};
\coordinate (point_to_label_B) at ($(B)!-7.5pt!(A)$);
\node at (point_to_label_B){$B$};

\coordinate (P) at (-0.75,-1.5);
\coordinate (Q) at (4,2);
\draw[latex-latex] (P) -- (Q);
\coordinate (point_to_label_ell) at ($(Q)!-7.5pt!(P)$);
\node at (point_to_label_ell){$\ell$};

\end{tikzpicture}

\end{document}

答案1

这就是你想要的吗?我只是用了node标题。不需要axis环境。

在此处输入图片描述

\documentclass[preview, border=4pt]{standalone}
\usepackage{amsmath}
\usepackage{amsfonts}

\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections}

\begin{document}

\begin{tikzpicture}

\coordinate (A) at (0,0);
\draw[fill] (A) circle (1.5pt);
\coordinate (B) at (1.5,2);
\draw[fill] (B) circle (1.5pt);
\draw (A) -- (B);

\coordinate (point_to_label_A) at ($(A)!-7.5pt!(B)$);
\node at (point_to_label_A){$A$};
\coordinate (point_to_label_B) at ($(B)!-7.5pt!(A)$);
\node at (point_to_label_B){$B$};

\coordinate (P) at (-0.75,-1.5);
\coordinate (Q) at (4,2);
\draw[latex-latex] (P) -- (Q);
\coordinate (point_to_label_ell) at ($(Q)!-7.5pt!(P)$);
\node at (point_to_label_ell){$\ell$};

% title
\node[align=center,font=\bfseries, yshift=2em] (title) 
    at (current bounding box.north)
    {An illustration of points $A$ and $B$\\ being on the same side of $\ell$};

\end{tikzpicture}

\end{document}

相关内容