Math & ScienceWeird included Graphics Output

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Weird included Graphics Output

Post by ghostanime2001 »

Hey guys its me again! sorry for creating so many posts! but i made my drawings in acrobat and cropped it instead & put it into latex to generate something like the attached file.

My problem: Why is there that "1.pdf" showing up? Also, how can I align my number with the diagram and the equations ?

This is what my latex looks like

Code: Select all

\documentclass[fleqn]{article}
\usepackage{fullpage}
\usepackage{graphicx}
\pagestyle{empty}
\begin{document}
\begin{enumerate}
\item 
\includegraphics{Diagram 1.pdf}
\end{enumerate}
\end{document}
in case anyone doesn't understand, I have included an example pdf to show what I mean.
Attachments
Diagramss.pdf
(196.63 KiB) Downloaded 253 times
Example.pdf
(36.27 KiB) Downloaded 219 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Weird included Graphics Output

Post by localghost »

ghostanime2001 wrote:[…] Why is there that "1.pdf" showing up? […]
Avoid blank spaces and other special characters like underscores in the path and the name of the file.
ghostanime2001 wrote:[…] Also, how can I align my number with the diagram and the equations?
Use minipage environments with appropriate parameters.


Thorsten
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Weird included Graphics Output

Post by ghostanime2001 »

I used the right environment + commands but I don't understand why my "1." the top of the diagram and the first line of the equation don't line up. Whatever else follows doesn't have to be aligned but those three things should align properly. I've tried everything. I don't know what else to do. Help!

here is my latex code:

Code: Select all

\documentclass[fleqn]{article}
\usepackage{fullpage}
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{amsmath}
\usepackage[makeroom]{cancel}
\pagestyle{empty}
\begin{document}
\begin{enumerate}
\item
\includegraphics{Diagram.pdf}
\begin{minipage}[t]{2in}
$\begin{aligned}[t]
v&=\cfrac{2\pi d}{T} \\
v&=\cfrac{2\pi r\cos\theta}{T} \\
v&=\cfrac{2\pi(\text{6.37\e{6} m})\cos\text{(40.1)}}{\text{86,400 s}} \\
v&=\text{354.34 m/s} \\
\end{aligned}$
\end{minipage}
\end{enumerate}
\end{document}
Attachments
LaTeX1.pdf
(205.99 KiB) Downloaded 183 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Weird included Graphics Output

Post by localghost »

The solution proposed in my last reply was not ideal. So I did another one.

Code: Select all

\documentclass[fleqn]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage[demo]{graphicx}
\usepackage{amsmath}
\usepackage{xfrac}
\usepackage{siunitx}
\sisetup{%
  output-decimal-marker={.},
  load-configurations=abbreviations,
  group-separator={,},
  per-mode=fraction,
  fraction-function=\sfrac
}
\usepackage{fix-cm}

\begin{document}
  \begin{enumerate}
    \item \raisebox{1.75ex}{\parbox[t]{2in}{\null\includegraphics[width=\linewidth]{Diagram.pdf}}}\quad
          \begin{math}
            \begin{aligned}[t]
              v &= \dfrac{2\pi d}{T} \\
              v &= \dfrac{2\pi r\cos\theta}{T} \\
              v &= \dfrac{2\pi(\SI{6.37e6}{\m})\cos\SI{40.1}{\degree}}{\SI{86400}{\s}} \\
              v &= \SI{354.34}{\m\per\s}
            \end{aligned}
          \end{math}
  \end{enumerate}
\end{document}
Since included graphics are always inserted with their baseline at the bottom, you have to cheat a little bit by the \null command, which only is defined as an empty box. Typesetting of physical units has been enhanced by the siunitx package.

Note the »demo« option for the graphicx package. It has only been inserted because the graphics was not present to me. Remove it before you continue.

And by the way, it is only kind and fair to mention a crossposting [1]. Those trying to help put a lot of effort into their answers. A short note would prevent them of double efforts and waste of time.

[1] {TeX} SE - Weird included Graphics Output
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Re: Weird included Graphics Output

Post by ghostanime2001 »

Does "1." align 1.75ex below the top of the diagram? (\raisebox{1.75ex} ??????)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Weird included Graphics Output

Post by localghost »

The top of the diagram by default aligns with the baseline of the current line. Since this wouldn't look so nice, the box with the diagram has to be raised (done here by 1.75ex).
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Re: Weird included Graphics Output

Post by ghostanime2001 »

So your saying that the base of the diagram is perfectly aligned with the bottom baseline of the equations and the numbers?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Weird included Graphics Output

Post by localghost »

At which point have I been unclear in my remarks? Not the base of the diagram is aligned with the baseline of the current line, it's its top. Why don't you just test my example and play around with it?
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Re: Weird included Graphics Output

Post by ghostanime2001 »

so you mean, The top of the diagram is aligned with the baseline of the text?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Weird included Graphics Output

Post by localghost »

What exactly is unclear? I already explained in detail how the graphic is aligned by default and with the trick from my first reply. It just needs to be adjusted. Compile the provided example and test different values for the raised box.
Post Reply