欢迎来到 TeX StackExchange
\usepackage{pdfcomment} \pdftooltip
我将尝试通过此包命令获取以下环境的alt 文本输出,例如Figures, Equations and Tables
。
我成功获得了以下环境的 alt-text 输出,例如Figures, Equations
。
但是,该\pdftooltip
命令不支持table
环境。Not in outer par mode
编译期间出现错误。
我在下面提到了我的 MWE:
\documentclass{article}
\RequirePackage{booktabs}
\RequirePackage{color}
\RequirePackage{colortbl}%
\RequirePackage[table]{xcolor}%
\RequirePackage{caption}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pdfcomment}
\usepackage{graphicx}
\newcommand{\tablehead}[1]{{\fontsize{9.5pt}{11.5pt}\selectfont#1}}
\definecolor{titlecolor}{cmyk}{1,0,0,0.25}
\definecolor{partcolor}{cmyk}{0.57,0.10,0.07,0}
\definecolor{chapternumcolor}{cmyk}{0.10,0,0,0.02}
\definecolor{tablegray}{cmyk}{0,0,0,0.10}
\begin{document}
\begin{figure}
\pdftooltip{\includegraphics{b-9781450361002-003-fig-001.eps}}{This is alt text for images.}
\caption{This is a caption for this figure. It is fairly long so we can make
sure it looks good when occupying more than one line. Here is one more
sentence to make it longer.}
\label{ch01.fig11.1.1}
\label{fig:query-specification}
\end{figure}
\begin{equation}
\pdftooltip{x^{3} + 6x^{2} -x = 30}{This text is sample Equation}
\end{equation}
\begin{equation}
\pdftooltip[]{\begin{aligned}
& a + b\\
&\quad = \frac{{ - b \pm \sqrt {{b^2} - 4ac} }}{{2a}}
\end{aligned}}{This text is aligned sample Equation}
\end{equation}
\pdftooltip{\begin{table}[!t]
\captionof{table}{Bandwidth Provided by HT.\label{b-9781450361002-003-tab-001}}
\rowcolors{1}{tablegray}{}
{\begin{tabular*}{180pt}{lccccccc}
\rowcolor{titlecolor} \tablehead{\textcolor{white}{Version}} & \tablehead{\textcolor{white}{Max. Aggregate Bidirectional Bandwidth (GB/s)}}\\
1.0 & 12.8\\
2.0 & 22.4\\
3.0 & 41.6\\
3.1 & 51.2\\
\end{tabular*}}{}
\end{table}}{Table text}
\end{document}
请您检查并建议如何解决此问题。
答案1
您不能将命令\pdftooltip
环绕浮点。在 中figure
,您做对了,您将它环绕在图形周围,而不是figure
环境周围。同样,对于表格,您需要将其环绕在表格周围,而不是环境周围table
。
\documentclass{article}
\RequirePackage{booktabs}
\RequirePackage{color}
\RequirePackage{colortbl}%
\RequirePackage[table]{xcolor}%
\RequirePackage{caption}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pdfcomment}
\usepackage{graphicx}
\newcommand{\tablehead}[1]{{\fontsize{9.5pt}{11.5pt}\selectfont#1}}
\definecolor{titlecolor}{cmyk}{1,0,0,0.25}
\definecolor{partcolor}{cmyk}{0.57,0.10,0.07,0}
\definecolor{chapternumcolor}{cmyk}{0.10,0,0,0.02}
\definecolor{tablegray}{cmyk}{0,0,0,0.10}
\begin{document}
\begin{figure}
\pdftooltip{\includegraphics{example-image-duck}}{This is alt text for images.}
\caption{This is a caption for this figure. It is fairly long so we can make
sure it looks good when occupying more than one line. Here is one more
sentence to make it longer.}
\label{ch01.fig11.1.1}
\label{fig:query-specification}
\end{figure}
\begin{equation}
\pdftooltip{x^{3} + 6x^{2} -x = 30}{This text is sample Equation}
\end{equation}
\begin{equation}
\pdftooltip[]{\begin{aligned}
& a + b\\
&\quad = \frac{{ - b \pm \sqrt {{b^2} - 4ac} }}{{2a}}
\end{aligned}}{This text is aligned sample Equation}
\end{equation}
\begin{table}[!t]
\captionof{table}{Bandwidth Provided by HT.\label{b-9781450361002-003-tab-001}}
\rowcolors{1}{tablegray}{}
\pdftooltip{{\begin{tabular*}{180pt}{lccccccc}
\rowcolor{titlecolor} \tablehead{\textcolor{white}{Version}} & \tablehead{\textcolor{white}{Max. Aggregate Bidirectional Bandwidth (GB/s)}}\\
1.0 & 12.8\\
2.0 & 22.4\\
3.0 & 41.6\\
3.1 & 51.2\\
\end{tabular*}}}{Table text}{}
\end{table}%
\end{document}