1

Welcome to TeX StackExchange

I will try to get the alt-text output through this package \usepackage{pdfcomment} \pdftooltip command for the following environments like Figures, Equations and Tables.

I got the alt-text output successfully for the following environments like Figures, Equations.

But, the \pdftooltip command didn't support the table environments. Not in outer par mode error has been throw during the compailation.

I have mentioned my MWE below:

\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}

Could, you please check and advice how to resolve this issue.

CS Kumar
  • 1,253

1 Answers1

1

You cannot wrap the command \pdftooltip around a float. In the figure, you did it right, you wrapped it around the graphics, not the figure environment. Likewise, for a table you need to wrap it around the tabular, not the table environment.

\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}
  • Many thanks for your quick response. I understand the logic how to work the \pdftooltip command through your solution. Your solution is working good. – CS Kumar Dec 10 '19 at 07:13