-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnamestack.tex
55 lines (51 loc) · 1.99 KB
/
namestack.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
%% \namestack for making overlay/superposed stacks of names/text
\usepackage[final]{pdfcomment} % for tooltips
\usepackage{accsupp} % for accessibility
\usepackage{pgf} % for transparency
% Usage: \textopacity{opacity}{text}
% transparency.sty doesn't blend well in Acrobat, so we use PGF;
% see https://tex.stackexchange.com/a/681324/245104
\newcommand\textopacity[2]{%
\begin{pgfpicture}%
\pgfsetfillopacity{#1}%
\pgfpathmoveto{\pgfpointorigin}%
\pgftext[base]{#2}%
\end{pgfpicture}%
}
% Usage: \textstack{opacity}{item1; item2; ...}
% Or: \textstack[sep]{opacity}{item1 sep item2 sep ...}
% Expands to \vbox{\hbox{item1}\vskip-\baselineskip\hbox{item2}...},
% plus a PDF tooltip, copy/paste override, and specified opacity.
% Loop iteration based on https://tex.stackexchange.com/a/159177/245104
\makeatletter
\newlength\textstack@height
\newcommand\textstack[3][;]{%
% Append separator (#1) and \@eol to end of input:
\def\textstack@append##1{\expandafter\textstack@step##1#1\@eol}%
% Split into first component (##1) up to separator (#1), and rest (##2):
\def\textstack@step##1#1##2\@eol{%
% Build \hbox for this component (##1) with specified opacity (#2),
% while saving height in \textstack@height
\setbox1=\hbox{\textopacity{#2}{\ignorespaces ##1\unskip}}%
\setlength\textstack@height{\ht1}%
\box1%
\ifx\@eol##2\@eol\else
% More steps: unwind vertical space and continue
\nointerlineskip
\vskip-\textstack@height
\textstack@step##2\@eol
\fi}%
% Tooltip with full author list (#3)
\pdftooltip{%
% Override copy/paste text with full author list (#3)
\BeginAccSupp{method=pdfstringdef,unicode,ActualText={#3}}%
% Wrap stack in \vbox
\vbox{\textstack@append{#3}}%
\EndAccSupp{}%
}{#3}%
}
\makeatother
% Usage: \namestack{name1; name2; ...}
% Or: \namestack[opacity]{name1; name2; ...}
% Like \textstack but with optional opacity defaulting to 2/3
\newcommand\namestack[2][0.666]{\textstack{#1}{#2}}