我在幻灯片的页脚处添加了一个标题时钟beamer
,如果使用 pdfLaTeX 编译,它可以正常工作;但如果使用 XeLaTeX 编译,时钟不会垂直对齐中间。我该如何解决这个问题。
这是我的 MWE:
\documentclass[10pt]{beamer}
\usepackage[font=Times,timeinterval=1]{tdclock}
\usetheme{Madrid}
\title{Title}
\author{Authors}
\institute{Institute}
\date[\initclock\tddate\ \ \tdtime]{\today}
\begin{document}
\frame{\titlepage}
\end{document}
答案1
引自tdclock
文档:
该包需要
hyperref
和xkeyval
包xcolor
。它PDFLATEX
与 以及LATEX→DviPs→Ps2pdf
序列一起使用。在 生成的文档中Dvipdfm
,时钟无法正常工作。
如果您使用xelatex
pdflatex 中没有的特殊字体,tdclock 似乎也可以正常工作,lualatex
并且还允许您使用特殊字体。
答案2
实现tdclock
过于复杂,容易出错。
以下是一个可与所有 TeX 引擎和后端一起正常运行的替代实现:
\documentclass{beamer}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Digital Clock Implementation
%
% Usage:
%
% % set-up (defaults)
% \def\clockfont{Helvetica} % or Times
% \def\clockfontscale{0.93}
% \def\clockformat{yyyy/mm/dd HH:MM:ss}
% \def\clockrefresh{1000} % milli-seconds
%
% % insert clock
% \digiclock
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{pdfbase}
\ExplSyntaxOn
\let\clockPdfAnnot\pbs_pdfannot:nnnn\let\clockPdfLastAnn\pbs_pdflastann:
\let\clockAppendToFields\pbs_appendtofields:n
\ExplSyntaxOff
\makeatletter
\def\clock@start#1#2#3{%
function showtime#3(){%
this.getField("digiclock.#3").value=util.printd("#1",new Date());%
this.dirty=false;%
}%
showtime#3();%
var digiclock#3=app.setInterval("showtime#3()",#2);%
}%
\newcounter{clock@num}%
\newlength\ex@height%
\newlength\clock@width%
\newlength\clock@height%
\def\digiclock{%
\settowidth\clock@width{\clockformat}%
\settoheight\clock@height{\clockformat}%
\settoheight\ex@height{X}%
\extractcolorspec{.}\clock@tempb% current color (\setcolor{...})
\expandafter\convertcolorspec\clock@tempb{rgb}\clock@tempb%
\edef\clock@tempa{\expandafter\clock@rgbcomp\clock@tempb\@nil}%
\raisebox{\depth}{%
\makebox[\clockfontscale\clock@width][l]{%
\clockPdfAnnot{\clockfontscale\clock@width}%
{\clockfontscale\clock@height}{\clockfontscale\clock@height}{%
/Subtype/Widget/FT/Tx/T (digiclock.\theclock@num) /Ff 1
/DA (/\clockfont\space 0 Tf \clock@tempa\space rg)
/MK<</BC []/BG []>>
/Q 2
/BS <</W 1/S/S>>
/AA <<
/PO <</S/JavaScript/JS(\clock@start{\clockformat}{\clockrefresh}{\theclock@num})>>
/PC <</S/JavaScript/JS(app.clearInterval(digiclock\theclock@num);)>>
>>
}%
}%
\vrule width 0pt height 0.5\ex@height depth 0.5\ex@height%
}%
\clockAppendToFields{\clockPdfLastAnn}%
\stepcounter{clock@num}%
}
\def\clock@rgbcomp#1,#2,#3\@nil{#1 #2 #3}
\makeatother
%default settings
\def\clockfont{Helvetica}
\def\clockfontscale{0.93}
\def\clockformat{yyyy/mm/dd HH:MM:ss}
\def\clockrefresh{1000}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usetheme{Madrid}
\date[\def\clockfontscale{1.1}\def\clockformat{HH:MM:ss}\digiclock]{\today}
\begin{document}
\begin{frame}
\LARGE current date \& time: \digiclock
\end{frame}
\end{document}
答案3
可能tdclock
和xelatex
不兼容。我尝试更改数据包本身,这是我的临时解决方案。
在文件中tdclock.sty
,更改的\def
可能\clockfield
会\pdfcolon
修复 xelatex 的这个问题。
我只是把盒子做得更大一些。
老的:
\def\pdfcolon{%
\clock@setfonsize\clock@setheight\clock@setfontcolor%\clock@setwidth
\setbox\sizebox=\hbox{\TextField[readonly=true, name=separatortime, width=0.90\clock@fontsize, height=\clock@height, align = 0, color =\clock@fontcolor, charsize = \clock@fontsize,value=:]{}}%
\vrule width 0pt height 2pt\kern-0.4pt\kern-\wd\sizebox\kern 0.90\clock@fontsize{\raisebox{-\b@h\clock@fontsize}{\raisebox{-\a@h pt}%
{\mbox{\TextField[name=separatortime, width=0.90\clock@fontsize, height=\clock@height, align = 0, color =\clock@fontcolor, charsize = \clock@fontsize,
readonly=true,value=:]{}\kern-0.90\clock@fontsize\kern\a@one pt\kern \b@one\clock@fontsize\vrule width 0pt height 2pt}}}}%
}
\def\clockfield#1{%
\clock@setfonsize\clock@setheight\clock@setfontcolor%\clock@setwidth
\setbox\sizebox=\hbox{\TextField[readonly=true, name=#1, width=1.31\clock@fontsize, height=\clock@height, align = 0, color =\clock@fontcolor, charsize = \clock@fontsize]{}}%
\vrule width 0pt height 2pt\kern-\a@a pt\kern-\wd\sizebox\kern 1.31\clock@fontsize{\raisebox{-\b@h\clock@fontsize}%
{\raisebox{-\a@h pt}{\mbox{\TextField[name=#1, width=1.31\clock@fontsize, height=\clock@height, align = 0, color =\clock@fontcolor, charsize = \clock@fontsize,readonly=true,
value={}]{}\kern-1.31\clock@fontsize\kern\a@a pt\kern \b@b\clock@fontsize\vrule width 0pt height 2pt}}}}%
}
新的:
\def\pdfcolon{%
\clock@setfonsize\clock@setheight\clock@setfontcolor%\clock@setwidth
\setbox\sizebox=\hbox{\TextField[readonly=true, name=separatortime, width=0.90\clock@fontsize, height=1.2\clock@height, align = 0, color =\clock@fontcolor, charsize = \clock@fontsize,value=:]{}}%
\vrule width 0pt height 2pt\kern-0.4pt\kern-\wd\sizebox\kern 0.90\clock@fontsize{\raisebox{-\b@h\clock@fontsize}{\raisebox{-\a@h pt}%
{\mbox{\TextField[name=separatortime, width=0.90\clock@fontsize, height=1.2\clock@height, align = 0, color =\clock@fontcolor, charsize = \clock@fontsize,
readonly=true,value=:]{}\kern-0.90\clock@fontsize\kern\a@one pt\kern \b@one\clock@fontsize\vrule width 0pt height 2pt}}}}%
}
\def\clockfield#1{%
\clock@setfonsize\clock@setheight\clock@setfontcolor%\clock@setwidth
\setbox\sizebox=\hbox{\TextField[readonly=true, name=#1, width=1.6\clock@fontsize, height=1.2\clock@height, align = 0, color =\clock@fontcolor, charsize = \clock@fontsize]{}}%
\vrule width 0pt height 2pt\kern-\a@a pt\kern-\wd\sizebox\kern 1.6\clock@fontsize{\raisebox{-\b@h\clock@fontsize}%
{\raisebox{-\a@h pt}{\mbox{\TextField[name=#1, width=1.6\clock@fontsize, height=1.2\clock@height, align = 0, color =\clock@fontcolor, charsize = \clock@fontsize,readonly=true,
value={}]{}\kern-1.6\clock@fontsize\kern\a@a pt\kern \b@b\clock@fontsize\vrule width 0pt height 2pt}}}}%
}