标题说明了一切。您如何向 TeXie 祝愿“新年快乐”?使用 pdfLaTeX 编译以下代码,使用“PDF 阅读器”或“Adobe Acrobat Pro”查看,然后按第二页上的“新年快乐”按钮。请在评论中添加您语言的翻译,建议如何将“新年快乐”字符串国际化。
\documentclass{scrartcl}
\setcounter{secnumdepth}{0}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{mathptmx}
\usepackage[scaled =.92]{helvet}
\usepackage{soul}
\setlength{\paperwidth}{5.2075in}
\setlength{\paperheight}{4.90in}
\renewcommand*{\familydefault}{phv}
\usepackage[pdftex,margin=0.5in]{geometry}
\usepackage{fancyhdr}
\lhead{A Sample Calculation}\chead{}
\rhead{Area of Circle}
\lfoot{}\cfoot{}\rfoot{}
\pagestyle{fancy}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage[pdftex,pdfpagelayout=SinglePage,
pdftitle={Wishing you a happy year},pdfsubject={Invest your new year improving your TeX skills}%
]{hyperref}
\definecolor{background}{rgb}{0.99,0.98,0.90}
\pagecolor{background}
\setlength{\parindent}{0.0cm}
\usepackage[pdftex]{insdljs}
\begin{insDLJS}[test]{test}{JavaScript}
function doCalculation()
{
var radius=0.0 + this.getField("radius").value;
this.getField("diameter").value=radius*2;
this.getField("areacircle").value= Math.PI * Math.pow(radius, 2);
}
function HappyNewYear()
{
app.alert("Happy New Year!",3);
}
\end{insDLJS}
%% This must be here
%\OpenAction{/S/JavaScript/JS(docOpen();)}
%% Short hand commands
\newcommand{\textforlabel}[2]{%
\TextField[name={#1}, value={#2}, width=9em,align=2,%
bordercolor={0.990 .980 .85},%
readonly=true]{}%
}
%% Define the heading
\newcommand{\heading}[1]{\so{#1}}
\def\spacer#1{\multicolumn{2}{|c|}{}\\*[#1]}
\begin{document}
\topskip=0pt
\vphantom{-Z}
\vfill
\begin{center}
\textbf{\Huge Have a Happy New Year\\ with JavaScript\\*[4pt] and LateX!}
\end{center}
\vfill
\newpage
\begin{Form}
\begin{tabular}{|rl|}
\hline
\multicolumn{2}{|c|}{}\\*[-0.8em]\multicolumn{2}{|c|}{%
\heading{Area of Circle}}\\
%%
%%% Input field radius
&\\*[-0.8em]\textforlabel{l01}{Radius:}&\TextField[name=radius,width=10em, bordercolor={0.650 .790 .94}]{}%
~m\\
&\\ \hline
\multicolumn{2}{|c|}{\heading{Calculate}}\\
\spacer{-0.8em}
\multicolumn{2}{|c|}{
%% Push button is defined here
\PushButton[name=start,onclick={doCalculation();},bordercolor={0.650 .790 .94}%
]{Calculate}
%% Push button is defined here
\PushButton[name=hello,%
onclick={HappyNewYear();}, bordercolor={0.650 .790 .94}%
]{Happy New Year!}
}\\
\spacer{-0.8em}
\hline
\multicolumn{2}{|c|}{\heading{Results}}\\
%% RESULTS
%% Diameter
\multicolumn{2}{|c|}{}\\*[-0.8em]\textforlabel{name=l04, bordercolor={0.650 0.790 0.94}}{%
Diameter :}&\TextField[name=diameter,width=10em,bordercolor={0.650 .790 .94},%
readonly=true]{}~m\\
\spacer{-0.8em}
\textforlabel{name=l05, bordercolor={0.650 0.790 0.94}}{Area:} & \TextField[name=areacircle,width=10em,%
bordercolor={0.650 .790 .94},readonly=true]{}~m$^2$\\*[-0.8em]
\spacer{1em}
\spacer{1em}
\hline
\end{tabular}
\end{Form}
\bigskip
\parindent0.5em
As proved by Archimedes, the area enclosed by a circle is $\pi$ multiplied by the radius squared \(\pi r^2\). Apollonius of Perga showed that a circle may also be defined as the set of points in a plane having a constant ratio (other than 1) of distances to two fixed foci, A and B.
Early science, particularly geometry and astrology and astronomy, was connected to the divine for most medieval scholars, and many believed that there was something intrinsically \textit{divine} or \textit{perfect} that could be found in circles. Some people still believe that the earth is still flat and is circular.
Some highlights in the history of the circle are:
\begin{enumerate}
\item 1700 BC -- The Rhind papyrus gives a method to find the area of a circular field. The result corresponds to \(\frac{256}{81}\) (3.16049\dots) as an approximate value of $\pi$.
\item 300 BC -- Book 3 of Euclid's Elements deals with the properties of circles.
In Plato's Seventh Letter there is a detailed definition and explanation of the circle. Plato explains the perfect circle, and how it is different from any drawing, words, definition or explanation.
\item 1880 -- Lindemann proves that $\pi$ is transcendental, effectively settling the millennia-old problem of squaring the circle
\item 1978 -- Donald Knuth develops \TeX\ in order to enable future generations to typeset Mathematics in a beautiful way, including all the equations that one can associate with circles.
\end{enumerate}
\end{document}
答案1
AdobeReader 提供大约 15 种不同的语言版本。这是您新年愿望的可能翻译数量。可以使用 JavaScript 对象访问打开 PDF 的阅读器的语言版本app.language
。请参阅:
它可用于选择匹配的问候语。我为法语和德语以及一些默认语言(根据说话者的数量)选择了该问候语。但是,可能需要安装额外的字体包 ;-) :
http://www.adobe.com/support/downloads/detail.jsp?ftpID=4883
HappyNewYear()
只需用以下代码替换函数的定义:
function HappyNewYear()
{
switch(app.lang){
case "FRA":
hny="Bonne Ann"+String.fromCharCode(233)+"e !";break;;
case "DE":
hny="Gl"+String.fromCharCode(252)+"ckliches Neues Jahr!";break;;
default:
hny=String.fromCharCode(26032,24180,24555,20048)+"!";
}
app.alert(hny,3);
}
请注意,一些非 ASCII 字符必须用其 Unicode 表示形式替换。