It is possible to have an interactive PDF
document, but will only probably work in Acrobat Reader. Some examples can be found at Hello World in pdfLaTeX and How do you say Happy New Year with LaTeX?.
There are a number of ways to create them but the simpler so far is to use the insdljs package from the AcroTeX Education Bundle.
To create the interactive part one needs to use PFD Forms and to insert the appropriate JavaScript code, which like in web pages is used to script the interactive part.
The insdljs
package provides an environment, similar to file contents for writing a JavaScript file. In the minimal it defines a function to calculate the area and diameter of a circle given its radius.
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);
}
The Textfields and push button are also defined accordingly. The MWE illustrates the application. Please view it with a compatible reader.
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{mathptmx}
\usepackage[scaled =.92]{helvet}
\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}
\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);
}
\end{insDLJS}
%% 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]{\textsc{#1}}
\begin{document}
\begin{center}
\textbf{\Huge Calculations\\ with JavaScript\\*[4pt] and pdfLateX!}
\end{center}
\newpage
\begin{Form}
\heading{Area of Circle}
%%
%%% Input field radius
\textforlabel{l01}{Radius:}
\TextField[name=radius,width=10em, bordercolor={0.650 .790 .94}]{}%
~m\\
%% Push button is defined here
\textforlabel{l02}{Press to calculate}
\PushButton[name=start,onclick={doCalculation();},bordercolor={0.650 .790 .94}%
]{Calculate}\\
\heading{Results}\\
%% RESULTS
%% Diameter
\textforlabel{name=l04}{%
Diameter :} \TextField[name=diameter,width=10em,bordercolor={0.650 .790 .94},%
readonly=true]{}~m
\textforlabel{name=l05}{Area:}
\TextField[name=areacircle,width=10em,%
bordercolor={0.650 .790 .94},readonly=true]{}~m$^2$\\*[-0.8em]
\end{Form}
\end{document}
The AcroTeX Education Bundle provides numerous other functions, which can be useful in an Academic environment for quizzes and tutorials.
Personally I am not very convinced, as such facilities can better be provided in web pages with better interactivity and opening other opportunities.
You can try
\documentclass{standalone}
\usepackage{color}
\usepackage{graphicx}
\begin{document}
\input{Colors.pdf_tex}
\end{document}
EDIT:
To address the problem with objects outside the pdf, you could define the size of the resulting pdf. But I am afraid, the numbers have to be adjusted for each figure.
\documentclass{standalone}
\usepackage{color}
\usepackage{graphicx}
\begin{document}
\parbox[c][30cm][c]{30cm}{
\hspace*{1cm}
\input{Colors.pdf_tex}
}
\end{document}
SECOND EDIT:
In fact standalone
itself is capable of adding desired margins. This can be done with
border={left right bottom top}
\documentclass[border={1cm 1cm 1cm 1cm}]{standalone}
\usepackage{color}
\usepackage{graphicx}
\begin{document}
\input{Colors.pdf_tex}
\end{document}
Best Answer
Pgfplots is a plotting package for 2d/3d visualization which can display
To activate it for all
pgfplots
figures in your document, simply writein your preamble.
Details, examples, and screenshots can be seen in the pgfplots manual http://pgfplots.sourceforge.net/pgfplots.pdf , here is an excerpt: