\begin{center}
\multido{\i=1+1}{41}{\includegraphics[page=\i]{trig_function-f1}
\end{center}
then i see animation (I use Adobe reader 8 and 9, in the both is the
same result) but with two unpleasant features:
1. first images are empty
2. images are not clipped to their natural size
When I use clip function in \includegraphic, than i have more unexpected
problems:
3. format of paper is changed to size of clipped images
4. i do not know, how to determined the bounding box.
If I take of measure of generated images and put this measures in
viewport, then I don't see the image ... (it is outside of measured
bounding box).
I thought, If it is possible to clip series images such, that paper size
is equal to image size, then the problem will be solved (I sow such
example in documentation for fancytooltips). But I dont know, how to do
this. It is also possible, that my approach is entirely wrong.
I like to use such generated animations in pdf book and also in Beamer
transparencies. Any suggestion is wery welcome!
regards, Zarko
%================== generation of image series =================%
\documentclass{article}
%---------------------------------------------------------------%
\usepackage{tikz}
\usepackage{multido}
%---------------------------------------------------------------%
\begin{document}
\pagestyle{empty}
\thispagestyle{empty}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\multido{\n=0+1}{41}{\noindent%
\begin{tikzpicture}
\clip (-0.5,-1.5) rectangle (5,2);
%--------
\draw[thin,->] (-2mm,0) -- (5,0) node[below left] {$t$};
\draw[thin,->] (0,-1.5) -- (0,2) node[above left,rotate=90]
{$y=\sin(t)$};
%--------
\draw[dashed] (0,0) sin (1,1) cos (2,0) sin (3,-1) cos (4,0);
%--------
\draw[fill=blue] (\n/10,{sin(\n*9)}) circle (1mm);
%--------
\end{tikzpicture}
\newpage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%================== presentation of animations =================%
\documentclass[a4paper]{article}
%---------------------------------------------------------------%
\usepackage{tikz,graphics}
\usepackage{multido}
%---------------------------------------------------------------%
\begin{document}
\pagestyle{empty}
\thispagestyle{empty}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\animation#1{%
\setbox0=\hbox{%
\includegraphics[page=#1]{trig_function-f1}%
% how to discover where is bounding box of a picture on the paper?
% and instead of above command use something like this
% \includegraphics[page=#1,viewport=bbllx bblly bburx bbury,clip] %
{trig_function-f1}%
% most of my tries failed ...
}
\newpage}
some text, some text, some text, some text, some text, some text, some
text, some text, some text, some text, some text
\begin{center}
\multido{\i=1+1}{41}{\animation{\i}}
\end{center}
some text, some text, some text, some text, some text, some text, some
text, some text, some text, some text
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
You could give the `animate' package a try. See below.
Alexander
%=== generation of embedded animation (Adobe Reader .ge. 7 )====%
\documentclass{article}
\usepackage{animate}
%---------------------------------------------------------------%
\usepackage{tikz}
\usepackage{multido}
%---------------------------------------------------------------%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{animateinline}[controls]{12}
\multiframe{41}{n=0+1}{
\begin{tikzpicture}
\clip (-0.5,-1.5) rectangle (5,2);
%--------
\draw[thin,->] (-2mm,0) -- (5,0) node[below left] {$t$};
\draw[thin,->] (0,-1.5) -- (0,2) node[above left,rotate=90]
{$y=\sin(t)$};
%--------
\draw[dashed] (0,0) sin (1,1) cos (2,0) sin (3,-1) cos (4,0);
%--------
\draw[fill=blue] (\n/10,{sin(\n*9)}) circle (1mm);
%--------
\end{tikzpicture}
}
\end{animateinline}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
The preview[1] package is perfect for this. Add this to your document
preamble (after loading tikz):
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
You will find the full code below.
Running the document through pdflatex will give you a PDF where each
page fit the graph perfectly.
You can find more details about TikZ and animations in the following
example:
http://www.fauskes.net/pgftikzexamples/animated-set-intersection/
[1] http://www.ctan.org/tex-archive/help/Catalogue/entries/preview.html
Hope this helps.
Regards,
Kjell Magne Fauske
Here is the modified example:
%================== generation of image series =================%
\documentclass{article}
%---------------------------------------------------------------%
\usepackage{tikz}
\usepackage{multido}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
%=== generation of embedded animation (Adobe Reader .ge. 7 )=====%
\documentclass{article}
\usepackage{animate}
%----------------------------------------------------------------%
\usepackage{tikz}
\usepackage{multido}
%----------------------------------------------------------------%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-------------------- write timeline file ---------------------%
\newwrite\TimeLineFile
\immediate\openout\TimeLineFile=sinus.txt
\immediate\write\TimeLineFile{%
%first frame:
% axes, labels, curve, _repeated_ until end of animation
% and put the filled circle in its first position on top
::0x0,1
}%
%remaining frames: overlay filled circle at its current postion
\multido{\i=2+1}{40}{%
\immediate\write\TimeLineFile{%
::\i % put filled circle on top
}
}
\immediate\closeout\TimeLineFile
%
%------------------- assemble animation -----------------------%
\begin{animateinline}[%
controls,timeline=sinus.txt,
begin={\begin{tikzpicture}\clip (-0.5,-1.5) rectangle (5,2);},
end={\end{tikzpicture}}
]{12}
%---- static material: axes, labels, curve ----%
\draw[thin,->] (-2mm,0) -- (5,0) node[below left] {$t$};
\draw[thin,->] (0,-1.5) -- (0,2) node[above left,rotate=90]
{$y=\sin(t)$};
\draw[dashed] (0,0) sin (1,1) cos (2,0) sin (3,-1) cos (4,0);
%----------------------------------------------%
\newframe
%------ dynamic material: filled circles ------%
\multiframe{41}{n=0+1}{
\draw[fill=blue] (\n/10,{sin(\n*9)}) circle (1mm);
}
%----------------------------------------------%
\end{animateinline}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
Nice example Alexander! I really like your animate.sty package.
Here is a somewhat unrelated question. Is it possible to use
animate.sty to create named layers? The application I have in mind is
to separate a complex drawing into multiple layers. The idea is to let
the users select which layers to view in the PDF viewer. Acrobat
Reader allows you to do this in the layers tab. In previous versions
of animate.sty each frame of the animation showed up in the layers
window. This is no longer the case. This is probably due to the
improved animation technique used in newer version.
Regards,
Kjell Magne Fauske
Thanks Kjell Magne!
> Here is a somewhat unrelated question. Is it possible to use
> animate.sty to create named layers? The application I have in mind is
> to separate a complex drawing into multiple layers. The idea is to let
> the users select which layers to view in the PDF viewer. Acrobat
> Reader allows you to do this in the layers tab. In previous versions
> of animate.sty each frame of the animation showed up in the layers
> window. This is no longer the case. This is probably due to the
> improved animation technique used in newer version.
>
> Regards,
> Kjell Magne Fauske
The use of PDF-Layers is still available (by means of `useocg' used as
a package or command option). However, the automatically named layers
do not show up in the Reader's Layers Pane as they used to do in older
versions of animate. (It slowed down the animation speed even further
wherefore I removed them from there.) But if you wish I can bring this
feature back.
Alexander
and the same with PSTricks
Herbert
\documentclass{article}
\usepackage{animate}
\usepackage{pstricks-add}
\usepackage{multido}
\begin{document}
%-------------------- write timeline file ---------------------%
\newwrite\TimeLineFile
\immediate\openout\TimeLineFile=sinus.txt
\immediate\write\TimeLineFile{::0x0,1}%
%remaining frames: overlay filled circle at its current postion
\multido{\i=2+1}{90}{%
\immediate\write\TimeLineFile{%
::\i % put filled circle on top
}}
\immediate\closeout\TimeLineFile
%------------------- assemble animation -----------------------%
\psset{xunit=\pstRadUnit}
\begin{animateinline}[controls,timeline=sinus.txt,
begin={\begin{pspicture}(-0.5,-1.5)(6.6,2)},
end={\end{pspicture}}]{9}
%---- static material: axes, labels, curve ----%
\psaxes[trigLabels,trigLabelBase=3]{->}(0,0)(-2mm,-1.5)(6.5,1.5)[t,-90][$y=\sin(t)$,0]
\psplot[xunit=1cm,linestyle=dashed,algebraic]{0}{\psPiTwo}{sin(x)}
\newframe
\multiframe{91}{n=0+4}{\psset{xunit=1cm,linecolor=blue}
\psdot[dotsize=3mm](!\n\space dup DegtoRad exch sin)
\psline[linestyle=dashed](!\n\space dup DegtoRad exch
sin)(!\n\space DegtoRad 0)
}
\end{animateinline}
\end{document}
>> Nice example Alexander! I really like your animate.sty package.
>> Here is a somewhat unrelated question.
That reminds me that I had an unrelated question/remark too:
What features should a pdf-viewer have to be able to show the animated
graphics? Is javascript enough? (I tried the portable version of the
viewer PDF-XChange which claims to have javascript support but neither
my animated boards nor the examples of the doc worked.)
--
Ulrike Fischer
>
> The use of PDF-Layers is still available (by means of `useocg' used as
> a package or command option). However, the automatically named layers
> do not show up in the Reader's Layers Pane as they used to do in older
> versions of animate. (It slowed down the animation speed even further
> wherefore I removed them from there.) But if you wish I can bring this
> feature back.
>
> Alexander
Now I understand why the layer names disappeared even if I used the
useocg option. Thanks for clearing that up. Someone asked on the pgf-
users mailing list if it was possible to create PDF layers using TikZ.
This is currently not possible, so I suggested they could use your
animate package as a workaround.
> I removed them from there.) But if you wish I can bring this
> feature back.
If it is not too much trouble you could make this an optional feature.
Would it be possible to have user-specified layer names? The
autogenerated names are good for animations, but if you want only want
to toggle layers on and of manually the generated names are not very
informative.
I see that my feature request is not directly related to animations,
but it could be useful in some cases.
- Kjell Magne Fauske
Looks great, Herbert! With the doubled number of frames the animation
is much smoother. However, to see the difference you should increase
the FPS setting in the PSTricks example to 24 instead of reducing it
to 9.
There is even buffer to further increase the speed. With your enhanced
example I get upto about 63 fps (command option `measure')
(Reader-8.1.2,
Linux, Core(TM)2 CPU 6600 @ 2.40GHz, nVidia NV44 [Quadro NVS 285])
Alexander
- OCG (PDF-Layers) are required for the control buttons, regardless of
whether `useocg' option is set or not
- Widget annotations of type /FT/Btn/Ff 65537 (non-interactive push
button field) and /FT/Btn/Ff 65536 (interactive push button field)
- JavaScript properties and methods of the `doc'(`this') object for
getting access to button field objects: this.numFields,
this.getNthFieldName(i), this.getField(<Field name>)
and OCGs of the current page: this.getOCGs(this.pageNum)
Returned Field objects must have the `display=display.hidden|
display.visible' property, OCG objects the `state=false|true' property
in order to set their visibility.
- JavaScript methods app.setInterval(), app.clearInterval() for the
dynamic effects
The rest is standard JavaScript, I believe.
> (I tried the portable version of the
> viewer PDF-XChange which claims to have javascript support but neither
> my animated boards nor the examples of the doc worked.)
I tried it too. I have already contacted the authors and even got an
answer. They will discuss the problem on their next project
development meeting.
Alexander
No problem.
> Would it be possible to have user-specified layer names? The
> autogenerated names are good for animations, but if you want only want
> to toggle layers on and of manually the generated names are not very
> informative.
I was afraid you would ask that. In order to get hands on the OCG
(Layer) objects within JavaScript their names are parsed and split
into the animation number and the frame number. This wouldn't be
possible with user defined names. However, I could imagine to prefix
the user defined name with the automatic numbering. This modified name
would finally appear in the layers list as well. Would this be
acceptable? Another problem is how to assign the name. This could be
done in the timeline file only.
Alexander
Great!
> > Would it be possible to have user-specified layer names? The
> > autogenerated names are good for animations, but if you want only want
> > to toggle layers on and of manually the generated names are not very
> > informative.
>
> I was afraid you would ask that. In order to get hands on the OCG
> (Layer) objects within JavaScript their names are parsed and split
> into the animation number and the frame number. This wouldn't be
> possible with user defined names. However, I could imagine to prefix
> the user defined name with the automatic numbering. This modified name
> would finally appear in the layers list as well. Would this be
> acceptable? Another problem is how to assign the name. This could be
> done in the timeline file only.
>
That is acceptable and using the timeline file is fine. Thank you for
taking a look at this. I realize that my feature request is outside
the scope of your animate.sty package, so don't put too much work into
it.
Regards,
Kjell Magne Fauske
> That is acceptable and using the timeline file is fine. Thank you for
> taking a look at this. I realize that my feature request is outside
> the scope of your animate.sty package, so don't put too much work into
> it.
Michael Ritzert posted code for making OCG layers. I don't think
it has been made into a package yet but it works nicely for
making layered drawings with TikZ:
<http://groups.google.dk/group/comp.text.tex/browse_thread/thread/4eb3b173df26324/6839ec81c59d0c51>
I someone is thinking of making a package out of this maybe a
key/value syntax should be prefered. Something like
\begin{layer}[name=foo,visible=true]
Stuff on visible layer.
\end{layer}
\begin{layer}[name=bar,visible=false]
Stuff on non-visible layer.
\end{layer}
\begin{layer}[name=baz,zoom=200-400]
Visible if zoom levels between 200 and 400.
\end{layer}
This is exactly what I was looking for. Thank you for the link! I will
try it out and see how it works.
Regards,
Kjell Magne Fauske
Michael Ritzert's code works very well. Thank you again Martin for
pointing it out. I agree that a key=value interface would be better.
Do you know if Michael Ritzert has done some more work on the package?
I noticed that you suggest a zoom option. Could not find anything
related to that in the code that you linked to.
Regards,
Kjell Magne Fauske
> Michael Ritzert's code works very well. Thank you again Martin for
> pointing it out. I agree that a key=value interface would be better.
> Do you know if Michael Ritzert has done some more work on the package?
No I don't know.
> I noticed that you suggest a zoom option. Could not find anything
> related to that in the code that you linked to.
Sorry. It was just ment as an example of the kinds of
functionality I would like to see in an ocg-layer package. It was
not specifically related to Michal Ritzert's code.
I have also bookmarked this thread on OCG:
<http://www.tug.org/pipermail/pdftex/2004-November/005411.html>
Kjell Magne, here is a solution that doesn't require any changes to
animate.sty and which works with and without OCGs (option `useocg').
The present solution has the advantage that Reader's layers pane which
is usually not open in Full Screen mode is not used.
It defines two commands
\ShowHideFrame{<anim No.>}{<frame No.>}{<link text>}
which creates a link that toggles the view of the specified frame, and
\GoToFrame{<anim No.>}{<frame No.>}{<link text>}
which creates a link that acts like a radio button, i. e. it goes to
the specified frame while hiding the current one.
It must only be kept in mind that <anim No.> and <Frame No.> are both
zero-based.
Alexander
--
Complete example:
%=== generation of embedded animation (Adobe Reader .ge. 7 )=====%
\documentclass{article}
%----------------------------------------------------------------%
\usepackage{animate}
\usepackage{tikz}
\usepackage{hyperref}
%----------------------------------------------------------------%
\makeatletter
% command to create toggle link to animation frame (push button)%
\newcommand{\ShowHideFrame}[3]{%
% #1: anim No. (zero-based),
% #2: frame No. (zero-based),
% #3: link text
\leavevmode%
\pdfstartlink user {
/Subtype /Link
/Border [\@pdfborder]%
/A <<
/S/JavaScript
/JS (
\if@anim@useocg%
if(a#1.fr[#2].state==true){
a#1.fr[#2].state=false;
}else{
a#1.fr[#2].state=true;
}
\else
if (a#1.fr[#2].display==display.visible){
a#1.fr[#2].display=display.hidden;
}else{
a#1.fr[#2].display=display.visible;
}
this.dirty=false; %reset document status to `unchanged'
\fi
)
>>
}#3%
\pdfendlink%
}
% command to create link that goes to particular frame while hiding
% the current one (radio button)
\newcommand{\GoToFrame}[3]{%
% #1: anim No. (zero-based),
% #2: frame No. (zero-based),
% #3: link text
\leavevmode%
\pdfstartlink user {
/Subtype /Link
/Border [\@pdfborder]%
/A <<
/S/JavaScript
/JS (
\if@anim@useocg
a#1.fr[a#1.idx].state=false;
a#1.idx=#2;
a#1.fr[#2].state=true;
\else
a#1.fr[a#1.idx].display=display.hidden;
a#1.idx=#2;
a#1.fr[#2].display=display.visible;
this.dirty=false;
\fi
)
>>
}#3%
\pdfendlink%
}
\makeatother
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{center}
\begin{animateinline}[width=0.6\linewidth,controls]{12}
\multiframe{41}{n=0+1}{
\begin{tikzpicture}
\clip (-0.5,-1.5) rectangle (5,2);
%--------
\draw[thin,->] (-2mm,0) -- (5,0) node[below left] {$t$};
\draw[thin,->] (0,-1.5) -- (0,2) node[above left,rotate=90]
{$y=\sin(t)$};
%--------
\draw[dashed] (0,0) sin (1,1) cos (2,0) sin (3,-1) cos (4,0);
%--------
\draw[fill=blue] (\n/10,{sin(\n*9)}) circle (1mm);
%--------
\end{tikzpicture}
}
\end{animateinline}\\[2ex]
\makebox[0.6\linewidth][r]{toggle frame:
\ShowHideFrame{0}{0}{$\sin 0$}
\ShowHideFrame{0}{10}{$\sin \frac{\pi}{2}$}
\ShowHideFrame{0}{20}{$\sin \pi$}
\ShowHideFrame{0}{30}{$\sin \frac{3}{2}\pi$}
\ShowHideFrame{0}{40}{$\sin 2\pi$}}\\
\makebox[0.6\linewidth][r]{go to frame:
\GoToFrame{0}{0}{$\sin 0$}
\GoToFrame{0}{10}{$\sin \frac{\pi}{2}$}
\GoToFrame{0}{20}{$\sin \pi$}
\GoToFrame{0}{30}{$\sin \frac{3}{2}\pi$}
\GoToFrame{0}{40}{$\sin 2\pi$}}
\end{center}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
Thank you Alexander for the example! It works perfectly and the code
is very educational. I probably have to read the PDF specs to fully
understand it, but that is maybe not a bad idea.
Regards,
Kjell Magne Fauske
Thanks for the link. I contacted the author. He was interested in
reviving the project again when he had some spare time.
Regards,
Kjell Magne Fauske
\documentclass[12pt]{article}
\usepackage{fp}
\usepackage{animate}
\usepackage{tikz}
\newcommand{\curve}[1]{%
\begin{tikzpicture}[domain=-3.6:3.6]
\clip (-6,-7) rectangle (6,7);
\draw[very thin,color=blue] (-4.2,-6.1) grid (4.2,6.29);
\draw[->] (-4.3,0) -- (4.3,0) node[right] {$x$};
\draw[->] (0,-6.2) -- (0,6.2) node[above] {$f(x)$};
\draw[ultra thick,color=blue] plot[id=1,domain=-2:2] function{x*x*x -
0.05*#1*x};
\draw[ultra thick,color=red] plot[id=1,domain=-2:2] function{-x*x*x +
0.05*#1*x};
\draw[ultra thick,color=green] (0,0) circle (#1*0.14cm);
\filldraw[ultra thick,fill=green] (0,0) circle ({#1*0.14-0.5}cm);
\draw[ultra thick,color=green] (0,0) circle ({#1*0.14-1}cm);
\end{tikzpicture}
}
\newcounter{param}
\setcounter{param}{-30}
\begin{document}
\begin{figure}
\centering
\begin{animateinline}
[width=0.6\linewidth,autoplay,controls,poster=last,loop]{10}%
\curve{\theparam}%
\whiledo{\theparam<30}{%
\newframe%
\addtocounter{param}{10}%
\curve{\theparam}%
}
\end{animateinline}%
\caption{javascript animation: needs {\color{magenta}animate}.
Reguires Adobe Reader}
\end{figure}
\end{document}
Your package animation do exactly this what i like to haw.
Since on may questions was so many suggestion and interesting
discussion, I need all this afternoon to test all solutions and read
documentation. About your package I have some further questions:
1. package generate two groups of buttons. The functions of left group
are obvios and easy to figured out, but the purpose of right group of
three buttons is still enigma to me (they have not any sensible action,
just stop animation for time of keeping them "on")
2. when I change the bk (back ground) colour of buttons, as it is
described in documentation, using RGB model they always become black
3. is there a way to say, that only left group of buttons appear on the
figure?
4. is there way that in the same features of animation is changed from
some frame further (a dummy example is below)? With test of frame
number? or is there frame counter?
Thank you very much for your answer and for great package!
Regards, Zarko
\documentclass{article}
\usepackage{animate}
\usepackage{tikz,verbatim}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
In example code below I try to achieve, that circulating dot is blue in
the first turn around and red at the second one. For this I
unsuccessfully try to use \verb+\ifnum +. Is there some best way to
achieve similar effect?
\begin{figure}[h]\centering
\begin{animateinline}[controls]{12}
\multiframe{81}{n=0+1}{
\begin{tikzpicture}
\clip (-4,-4) rectangle (4,4);
%--------
\draw[thin,->] (-4,0) -- (4,0) node[below left] {$\perp y$};
\draw[thin,->] (0,-4) -- (0,4) node[below left] {$y$};
%---
\draw[dashed] (0,0) circle (30mm);
%--------
% \ifnum \n<40
\draw[blue,fill=blue] (3*{cos(\n*9)},3*{sin(\n*9)}) circle (2mm);
% \else
%\draw[red,fill=red] (3*{cos(\n*9)},3*{sin(\n*9)}) circle (2mm)
% \fi;
%--------
\end{tikzpicture}
}
\end{animateinline}
\caption{Some dummy example.}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
[...]
Dear Kjell Magne Fauske,
thank you for your answer and specially for pointer to your home page
where the animations with TikZ are described. There are found many
answer to my further questions! It helps me a lot!
I have one further question regarding to TikZ. How to test if the some
mathematical expression have value smaller or great then zero?
I try with function \ifnum, but without any success. I dont know how a
value of a some math expression present to it as number. For example:
if cos(\n)>0 % how to form correct test?
\draw[blue,-*] (\n,0) -- (\n,{cos(\n)})
else
\draw[red,-*] (\n,0) -- (\n,{cos(\n)})
\fi
best regards, Zarko
[...]
Thank you to all, who response on my questions. Given suggestion solve
many of my starting problems at animation, but in your discussion I
discover many interesting things, which will help me at my work.
best regards, Zarko
usually helps, if you read a documentation more carefully. It is
explained on the page 7 at description of control. and it works as is
sayed. ... sorry for my superficiality!
regards, Zarko
>
> I have one further question regarding to TikZ. How to test if the some
> mathematical expression have value smaller or great then zero?
>
> I try with function \ifnum, but without any success. I dont know how a
> value of a some math expression present to it as number. For example:
>
> if cos(\n)>0 % how to form correct test?
> \draw[blue,-*] (\n,0) -- (\n,{cos(\n)})
> else
> \draw[red,-*] (\n,0) -- (\n,{cos(\n)})
> \fi
>
> best regards, Zarko
PGF's mathematical engine can help:
\pgfmathparse{greater(cos(\n),0)}
\ifdim\pgfmathresult pt>0pt
\draw[blue] (\n,0) -- (\n,{cos(\n)});
\else
\draw[red] (\n,0) -- (\n,{cos(\n)});
\fi
The greater(x,y) function returns 1 if x > y. The result is stored in
\pgfmathresult as an dimension. I recommend reading the part of the
PGF manual that describes the mathematical engine to get an overview
of the possibilities.
Hope this helps!
Regards,
Kjell Magne Fauske
PS. Sorry for hijacking your thread with all the PDF layers/ocg
questions.
Thank you very much, Kjell Magne!
Just little before I found similar solution, probably less elegant:
\pgfmathparse{cos(\n*9)>0}
\let\m=\pgfmathresult
\ifnum \m<1
\draw[blue] (\n,0) -- (\n,{cos(\n)});
\else
\draw[red] (\n,0) -- (\n,{cos(\n)});
\fi
>
> PS. Sorry for hijacking your thread with all the PDF layers/ocg
> questions.
No, not be sorry! This discussion was very interesting to me. It open me
a new view on pdf documents. Honestly, I'm not familiar with pdf very
much, but the layers, i.e. ocg are look like a solutions for this what I
like to achieve some day with my pdf documents.
Can you suggest me some introduction reading about this topic?
Regards, Zarko
>
> > PS. Sorry for hijacking your thread with all the PDF layers/ocg
> > questions.
>
> No, not be sorry! This discussion was very interesting to me. It open me
> a new view on pdf documents. Honestly, I'm not familiar with pdf very
> much, but the layers, i.e. ocg are look like a solutions for this what I
> like to achieve some day with my pdf documents.
>
> Can you suggest me some introduction reading about this topic?
>
I am quite new to this myself, so unfortunately I don't have any good
links. The PDF specification itself is probably a good place to start:
http://www.adobe.com/devnet/pdf/pdf_reference.html
- Kjell Magne Fauske