How to control the size of a pstricks \psfigure? - latex

I would like to use pst-optic to create some figures in a A4 landscape page and use the full size of the paper.
I have a two lenses system that I would like to draw.
The code I wrote is the following :
\documentclass[a4paper,12pt,landscape]{report}
\usepackage{auto-pst-pdf}
\usepackage{pst-optic}
\begin{document}
\begin{pspicture*}(-7.5,-5)(8,8)
\rput(0,0){\lens[lensScale=1.5,yBottom=-5,yTop=5,XO=-4,focus=1.5,OA=-2.5,AB=2,lensGlass=false, lensWidth=0.05]}
\Transform
\rput(0,0){\lens[lensScale=1.5,yBottom=-5,yTop=5,XO=3.5,focus=2,lensTwo=true,lensGlass=false,lensWidth=0.05]}
\end{pspicture*}
\end{document}
My problems are the following:
Whatever the size I enter in the pspicture command, I can't obtain the full drawing of the rays in the picture
I can't change the size of the pspicture environment to occupy the full size of the page
Can someone explain to me how to fix this ?
Best regards

Related

Highstock print size

I'm trying to use the print() function on a Highstock chart, but its not printing well when my chart is very large (almost full screen, for example 1800x1000 pixels),
The problem is that it prints over multiple pages, and also most part of the right half of the chart gets cut off...
Is there a way to resize the chart before printing (but not resize on screen), or is there some sort of "scale to fit page" functionality?
Basically I just want it to look nice on a4 / letter paper format.
Take a look at the exporting parameters here. You can specify scale and sourceWidth and sourceHeight. As for "look nice" you will have to play around with the sizes until you reach this subjective goal.

LaTeX - Automatically scale down an area so that it will be inside a page if it's too big?

I'm making a document in LaTeX. It includes a set of images in a row. A small percentage are quite wide and will stretch and push off the page. If I shrink all the image sequences then most of them will look too small. However it's not easy to figure out what sets are going to be too large. I'd like some automatic way to resize these sets.
Is there anyway to surround something with a command which will shrink it enough so that it fits within the width of the page? If it's already narrower than the page, then no shrinking is necessary?
you can do something like
\includegraphics[width=\textwidth]{figure}
or
\includegraphics[width=0.33\textwidth]{figure}
\includegraphics[width=0.33\textwidth]{figure}
\includegraphics[width=0.33\textwidth]{figure}
You may try the following macro:
\maxsizebox{〈width〉}{〈height〉}{〈content〉}
It only resizes the content if its natural size is larger than the given 〈width〉 or 〈height〉, but does not change the aspect ratio.
It is part of the adjustbox package. So you need to append to the preamble of your document:
\usepackage{adjustbox}
You can further read about it here.
The best way to scale down a big figure is this
\begin{figure}[!ht] \centering
\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{"path to your figure"}
\caption{"your caption"}
\label{"your label"}
\end{figure}

dealing with large figures in Latex

I have a large figure that appears at the end of my document rather than in the section that I want to be in. Even \begin{figure}[h] doesn't help. Without scaling it down, how can I put it at the end of the section I want it in?
Using the afterpage package can be a good solution. However, using the option here you are trying to tell LaTeX where you want to put the image. Instead, you need to tell LaTeX where the image is good to be put:
use \begin{figure}[tb] for figures that fit well in a page with text (say, half of the text height for the figure and the other half for the text)
use \begin{figure}[p] for floats large enough to require a dedicated page.
Setting a proper option increase your chances to have the image almost where you want, having at the same time a good page layout.
If the figure is still too far from the page where it should be placed, you can set some "barriers" for floats positioning with the packages placeins or afterpage (already mentioned).
Here is a small tutorial for float placement. The thing you want to do is put an \afterpage{\clearpage} command at the end of the section. This will create an additional page after the current one and place the floats that are left in the queque there. If the float still doesn't get placed, you have to resize it. If you really don't want to resize it and it should fit on the page, then you could try changing the margins and text area temporarily (i.e. just for that one page) and see if that lets the float get placed.
i forget if it's the float or array package that provides this, but,
\begin{figure}[H]
...
\end{figure}
The upper case H will put the figure exactly where it is in your code.

The way to find out whole picture width in PGF (Latex)

I've got a latex macro that draws a picture using PGF and Tikz according to given parameters. The width of picture drawn depends on these parameters.
PGF automatically calculates the resulting width of any picture drawn so the user does not have to set it explicitly(like for example when using latex build in picture environment).
However I need to know the width of picture that will be drawn. Of cause I could calculate it as the PGF does but this is going to be quite some work(a lot of if statements...). Is there a way to ask PGF what is the width of picture that is to be drawn (some command I expect)? Either inside tikzpicture environment or just after it?
Thanks for help.
What I would probably do is put the tikzpicture environment in a box, and then find the width of the box:
\setbox0=\vbox{\hbox{%
\begin{tikzpicture}
% ...
\end{tizpicture}%
}}
The width of the following picture is {\the\wd0}.
\box0
Note that after you run \box0, the box will be inserted into the document and its contents will be destroyed; you thus need to query the width of the box before you do that. If you want to save the width, you can store it in a dimension register with \dimen0=\wd0; alternatively, you can use \copybox0, which inserts the box but doesn't destroy it (although this might leak memory).
Also, having played with some of this before, I found that using just a \vbox caused the box to always be the full width of the page (which, if you think about it, makes sense); however, using just an \hbox caused the unboxing to fail for some reason (it seemed to be a known pug). Using both like this works, however—I'm using something very much like this to render TikZ pictures to PDF files of precisely the right size.

How to modify the paper dimensions in plain TeX?

I mean the whole paper, not only the text zone in it.
I want the dvi output to look 1 centimetre x 10 metres in the viewer if
I set these dimensions in the tex file.
And I don't want to go through LaTeX for it.
Add \special{papersize=1cm,1000cm} in the first page of the document. This is really a dvips extension, but many dvi viewers understand it. (And of course set \hsize, \vsize etc. to control the positioning of text.)
A couple of useful links:
The size of printed output and
Getting the right paper geometry from (La)TeX.
Of course, googling is much more efficient once I get the answer.

Resources