我正在尝试使用 XeLaTeX 排版具有平行列的文档(使用paracol
)。在文档中,我希望有注释的工具提示。我使用的代码来自https://tex.stackexchange.com/a/120005/97086。工具提示显示在左侧,但不显示在另一侧。是否可以使工具提示显示在两侧?
以下是 MWE:
\documentclass[12pt,oneside]{book}
\usepackage{xeCJK}
\usepackage{paracol}
\usepackage{fontspec}
\usepackage[marginparwidth=2.2cm]{geometry}
\usepackage{amsfonts}
\setCJKmainfont{MOESongUN}
\setCJKmonofont{TW-Sung-Ext-B}
\setmainfont{Charis SIL}
\newcommand{\ver}[1]{\textsuperscript{#1 }\nolinebreak}
\newcommand{\paral}[2]{
\begin{column*}
#1
\end{column*}
\begin{column}
#2
\end{column}}
\usepackage{xparse,pdfbase,ocgbase}
\usepackage{xcolor,calc}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\ExplSyntaxOn
\let\tpPdfLink\pbs_pdflink:nn
\let\tpPdfAnnot\pbs_pdfannot:nnnn\let\tpPdfLastAnn\pbs_pdflastann:
\let\tpAppendToFields\pbs_appendtofields:n
\def\tpPdfXform{\pbs_pdfxform:nnn{1}{1}}
\let\tpPdfLastXform\pbs_pdflastxform:
\ExplSyntaxOff
\makeatletter
\NewDocumentCommand{\tooltip}{ssO{black}mO{yellow!20}m}{{%
\leavevmode%
\IfBooleanT{#1}{%
\ocgbase@new@ocg{tipOCG.\thetcnt}{%
/Print<</PrintState/OFF>>/Export<</ExportState/OFF>>%
}{false}%
\xdef\tpTipOcg{\ocgbase@last@ocg}%
}%
\tpPdfLink{%
\IfBooleanTF{#2}{%
/Subtype/Link/Border [0 0 0]/A <</S/SetOCGState/State [/Toggle \tpTipOcg]>>
}{%
/Subtype/Screen%
\IfBooleanTF{#1}{%
/AA<<%
/E<</S/SetOCGState/State [/ON \tpTipOcg]>>%
/X<</S/SetOCGState/State [/OFF \tpTipOcg]>>%
>>%
}{
/AA<<%
/E<</S/JavaScript/JS(%
var fd=this.getField('tip.\thetcnt');%
\IfBooleanF{#1}{%
if(typeof(click\thetcnt)=='undefined'){%
var click\thetcnt=false;%
var fdor\thetcnt=fd.rect;var dragging\thetcnt=false;%
}%
}%
if(fd.display==display.hidden){%
fd.delay=true;fd.display=display.visible;fd.delay=false;%
}%
this.dirty=false;%
)>>%
/X<</S/JavaScript/JS(%
if(!click\thetcnt&&!dragging\thetcnt){fd.display=display.hidden;}%
if(!dragging\thetcnt){click\thetcnt=false;}%
this.dirty=false;%
)>>%
/U<</S/JavaScript/JS(click\thetcnt=true;this.dirty=false;)>>%
/PC<</S/JavaScript/JS (%
var fd=this.getField('tip.\thetcnt');%
try{fd.rect=fdor\thetcnt;}catch(e){}%
fd.display=display.hidden;this.dirty=false;%
)>>%
/PO<</S/JavaScript/JS(this.dirty=false;)>>%
>>%
}
}%
}{{\color{#3}#4}}%
\sbox\tiptext{\fcolorbox{black}{#5}{#6}}%
\edef\twd{\the\wd\tiptext}%
\edef\tht{\the\ht\tiptext}%
\edef\tdp{\the\dp\tiptext}%
\measureremainder{\whatsleft}\tipshift=0pt%
\ifdim\whatsleft<\twd\setlength\tipshift{\whatsleft-\twd}\fi%
\tpPdfXform{\tiptext}%
\raisebox{\heightof{#4}+\tdp}[0pt][0pt]{\makebox[0pt][l]{\hspace{\tipshift}%
\tpPdfAnnot{\twd}{\tht}{\tdp}{%
/Subtype/Widget/FT/Btn/T (tip.\thetcnt)%
/AP<</N \tpPdfLastXform>>%
/MK<</TP 1/I \tpPdfLastXform/IF<</S/A/FB true/A [0.0 0.0]>>>>%
\IfBooleanTF{#1}{%
/Ff 65537/OC \tpTipOcg%
}{%
/Ff 65536/F 3%
/AA <<%
/U <<%
/S/JavaScript/JS(%
var fd=event.target;%
var mX=this.mouseX;var mY=this.mouseY;%
var drag=function(){%
var nX=this.mouseX;var nY=this.mouseY;%
var dX=nX-mX;var dY=nY-mY;%
var fdr=fd.rect;%
fdr[0]+=dX;fdr[1]+=dY;fdr[2]+=dX;fdr[3]+=dY;%
fd.rect=fdr;mX=nX;mY=nY;%
};%
if(!dragging\thetcnt){%
dragging\thetcnt=true;Int=app.setInterval("drag()",1);%
}%
else{app.clearInterval(Int);dragging\thetcnt=false;}%
this.dirty=false;%
)%
>>%
>>%
}%
}%
\tpAppendToFields{\tpPdfLastAnn}%
}}%
\stepcounter{tcnt}%
}}
\makeatother
\newsavebox\tiptext\newcounter{tcnt}
\newlength{\whatsleft}\newlength{\tipshift}
\newcommand{\measureremainder}[1]{%
\begin{tikzpicture}[overlay,remember picture]
\path let \p0 = (0,0), \p1 = (current page.east) in
[/utils/exec={\pgfmathsetlength#1{\x1-\x0}\global#1=#1}];
\end{tikzpicture}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\nt}[1]{\mbox{-{}-#1}}
\newcommand{\note}[1]{\tooltip*{$^\star$}{#1}}
\begin{document}
\columnratio{0.4}
\footnotelayout{m}
\begin{paracol}{2}
\paral{\ver{20}上帝講:「水著生湠濟濟有活命的動物;鳥\note{「鳥」,本文,「有翼的類」。}飛佇地的頂面,天裡的穹蒼\note{「穹蒼」,本文,「穹蒼的面」。}。」}{\ver{20}Siōng-tè kóng: ``Tsuí tio̍h senn-thuànn tsē-tsē ū ua̍h-miā ê tōng-bu̍t; tsiáu\note{\textit{Tsiáu}, pún-bûn, \textit{ū si̍t ê luī}.} pue tī tē ê tíng-bīn, thinn\nt{lí} ê kiong-tshong\note{\textit{Kiong-tshong}, pún-bûn, \textit{kiong-tshong ê bīn}.}.''}
\end{paracol}
\end{document}
有趣的是,如果我使用\tooltip
而不是\tooltip*
,将鼠标悬停在右侧的工具提示上会使左侧的相应工具提示显示出来。