我一直在努力使我的讲义尽可能容易理解,并且我已经开始学习三角学课程(我仍然是 LaTeX 的新手)。但是,我遇到了一些问题,因为我知道如何向图像等添加替代文本,但不知道如何向使用 Tikz 包创建的图形添加替代文本。所以,我的问题是,有没有办法将替代文本添加到像下面的代码这样的简单内容中?
\documentclass[tikz,border=12pt]{standalone}
\begin{document}
\begin{tikzpicture}[]
\coordinate (origo) at (0,0);
\coordinate (pivot) at (1,5);
\fill[black] (origo) circle (0.05);
\draw[thick,gray,->] (origo) -- ++(3,0) node(mary)[black,right] {$x$};
\draw[thick,gray,->] (origo) -- ++(0,3) node[black,right] {$y$};
\draw[thick] (origo) -- ++(45:3) coordinate (bob);
\fill (bob) circle (0.05);
\node[] at (1.2,1.5){r};
\end{tikzpicture}
\end{document}
因此,当屏幕阅读器遇到这种情况时,它会读取类似“该图片是一架飞机,上面有一个点......和一条令人放心的线......”
答案1
由于图表很大,最好设置一个特定的图标(这里是红色的\Homer
),悬停在上面即可获取文本。如果您在整个演示文稿中统一图标,读者可以快速了解要点。
\documentclass[border=12pt]{standalone}
\usepackage{pdfcomment,tikz,simpsons}
\begin{document}
\pdftooltip{\textcolor{red}{\Homer}}{A graph in a plane with a point at ...}
\begin{tikzpicture}[]
\coordinate (origo) at (0,0);
\coordinate (pivot) at (1,5);
\fill[black] (origo) circle (0.05);
\draw[thick,gray,->] (origo) -- ++(3,0) node(mary)[black,right] {$x$};
\draw[thick,gray,->] (origo) -- ++(0,3) node[black,right] {$y$};
\draw[thick] (origo) -- ++(45:3) coordinate (bob);
\fill (bob) circle (0.05);
\node[] at (1.2,1.5){r};
\end{tikzpicture}%
\end{document}
你可以进一步将他插入图表中:
\documentclass[border=12pt]{standalone}
\usepackage{pdfcomment,tikz,simpsons,stackengine}
\begin{document}
\stackinset{r}{10pt}{b}{20pt}
{\pdftooltip{\textcolor{red}{\reflectbox{\Homer}}}
{A graph in a plane with a point at ...}}
{
\begin{tikzpicture}[]
\coordinate (origo) at (0,0);
\coordinate (pivot) at (1,5);
\fill[black] (origo) circle (0.05);
\draw[thick,gray,->] (origo) -- ++(3,0) node(mary)[black,right] {$x$};
\draw[thick,gray,->] (origo) -- ++(0,3) node[black,right] {$y$};
\draw[thick] (origo) -- ++(45:3) coordinate (bob);
\fill (bob) circle (0.05);
\node[] at (1.2,1.5){r};
\end{tikzpicture}%
}
\end{document}
答案2
正如评论中提到的,您只需在节点中添加工具提示即可。
\documentclass[tikz,border=12pt]{standalone}
\usepackage{pdfcomment}
\begin{document}
\begin{tikzpicture}
\coordinate (origo) at (0,0);
\coordinate (pivot) at (1,5);
\draw[thick,gray,->] (origo) -- ++(3,0) node(mary)[black,right]
{\pdftooltip{$x$}{horizontal coordinate}};
\draw[thick,gray,->] (origo) -- ++(0,3) node[black,right]
{\pdftooltip{$y$}{vertical coordinate}};
\draw[thick] (origo) --node[anchor=-45]{\pdftooltip{$r$}{radius}} ++(45:3) coordinate (bob);
\fill[black] (origo) circle[radius=0.05] (bob) circle[radius=0.05];
\end{tikzpicture}
\end{document}