# Posting Questions

I am more than happy to help you should you have a question about LaTeX or any related topic. After all, your question help improve my blog and give me ideas for new posts. I try to answer as many questions as possible and in general, I manage to get back to you relatively quickly. In order to make your life and mine easier, I put together these few points that I would ask you to consider before posting a question:

Minimal example
Please provide a minimal working example that I can copy and paste into a TeX document to reproduce your problem. Here are some instructions on minimal examples in LaTeX. Sometimes it may be difficult to describe the issue or to reproduce your problem. Furthermore, it will save us both time, confusion and you have a much better chance that I can help you when a minimal example is provided. Finally, there is a good chance that you’ll solve the problem yourself while creating a minimal example. If so, you are of course welcome to post the question along with the solution.

Posting code
Wordpress has a set of tools that make sourcecode look nice. Briefly, you can use tags of the following form for your LaTeX code:

[sourcecode language="latex"]

[/sourcecode]

Please go through the questions/comments that other people posted, there is a good chance that you will find the answer there. If there are lots of comments, use ctrl-f to search for key-words.

Is the question related to post?
In order for others to benefit from your question and potential answers, please try to find a post that is related to your question. You may use the search field on the right to find related posts. If there is no post, just use the one that you think is the most related to your question.

Suggestions, critiques or general comments
Please use the form on the About page for suggestions, critiques or general comments. They will be e-mailed to me and never published.

Thank you for your consideration.

1. Humberto

Hi Tom,
I am using the mini example below. Then in the generated pdf file the caption and the figure have too long separation. Please, suggest me some idea to reduce this distance.

Regards,
Humberto

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[!htp]
\centering
\includegraphics[viewport=-80 480 950 600, width=8in,height=5.0in,keepaspectratio]{Doc2.eps}
\caption[Graph of the quadratic function]{Graph of the quadratic function $y=f(x)=\frac{\pi}{2}\sin{(\pi x)}$}\label{fig:graph1}
\end{figure}
\end{document}
• Hi Humberto!

Wow, I didn’t know these includegraphics-options. Two things that I noticed with the set of options you use.

1. viewport crops the image. The first two numbers indicate the part of the image that is removed from the bottom left corner. A negative number doesn’t make sense there.
2. You use absolute width and height, and fix the aspect-ratio at the same time. Try either width or height and keepaspectratio or just width and height.

To keep things simple, I suggest you use textwidth as a unit, it keeps the aspect-ratio. In case you need to crop your image, viewport is fine, but use positive numbers. Here is an example:

\includegraphics[viewport=10 10 480 480, width=0.8\textwidth]{Doc2.eps}

Hope it helps!

Best, Tom.

2. Humberto

Hi Tom,
Thanks for your suggestion. I tried it, but the separation between the graph and the caption increased. Can this problem be initiated with the creation of the eps file? I used a graph that was in pdf and I saved as eps file.

Thanks,

Humberto

• Hi Humberto,

I’m so sorry, I just noticed that I forgot an important detail. You need to use the starred version of includegraphics to crop the image. Otherwise, it gets shifted, which is what you observe. Here is an example:

\includegraphics*[viewport=0 0 100 100]{Doc2.eps}

Thanks for your comment,
Tom.

3. Humberto

Hi Tom,

Thanks again, but with these commands only the captions appears, not the graph.

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[!htp]
\centering
\includegraphics*[viewport=0 0 100 100]{Doc2.eps}
\caption[Graph of the quadratic function]{Graph of the quadratic function $y=f(x)=\frac{\pi}{2}\sin{(\pi x)}$}\label{fig:graph1}
\end{figure}
\end{document}

Humberto

• Hey Humberto,

Did you change the crop size? It may be that your figure is just white in the bottom-left 100x100pts. Best, Tom.

4. Humberto

Hi Tom

Using the Window below, the starred version of includegraphics did not show the figure, however this command shows the figure with the large distance from the caption.

\includegraphics[viewport=0 200 780 780]{Doc2}

The figure was created using a testgenerator sofware and pasted in microsoft word, then I saved it as pdf file, and I transformed in an eps figure. You maybe right the figure is just white in the bottom-left. How much I need to crop it, such that I can get a reasonable distance between the figure and the caption?

• Hey Humberto,

I’m not sure what your figure looks like, so I can’t really tell you much about the values you should use. However, you may want to try using bb instead of viewport. Apparently, viewport are the coordinates relative to the bounding box (bb) of the graph. See the graphicx guide for the definition.

Your approach to get the eps-figure surprises me. Does your test-generator software not provide a way to export figures? If not, MS Paint may be a better choice than Word.

Best, Tom.

5. Humberto

Thank you so much for your suggestions to fix my problem with the space between figures and the caption. I finally fixed it using the command trim in

\includegraphics[trim =0in 7in 1in 0.2in, scale=.45]{graphs}

Regards,
Humberto

• Hey Humberto,

Thanks for providing your solution. I actually wrote a post on the topic. I forgot to sent you a message, sorry.

For the future, please try to find a post where your question fits best. You can use the search field on the right.

Thanks, Tom.