Graphics, Figures & TablesNo Graphics with included File

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

No Graphics with included File

Post by Singularity »

Hi folks. What's wrong with my latex code? There is no figure where there should be, just lots of blank space. I'm pretty sure nothing is wrong in SandM.tex because I've used it before. Thanks.

Thanks.

Main doc
--------

Code: Select all

\documentclass[12pt,fleqn,reqno]{article}
\usepackage{amsfonts,graphics,epsfig,cite}
\usepackage{amsmath,graphicx,amssymb,amsthm}

\usepackage{tikz}
\usepackage{graphicx}
\usepackage[margin=1.5in]{geometry}

\begin{document}

blah blah blah

\include{SandM.tex}

yada yada yada

\end{document}
SandM.tex (not what you're thinking!)
-------------------------------------

Code: Select all

% Graphical Spring and Mass system

\begin{center}
\begin{tikzpicture}
%   \draw[step=0.25cm,color=gray] (-1,-1) grid (1,1);
%   \draw [->] (-1.5,0) -- (1.5,0) node [below] {$x$};
%   \draw [->] (0,-1.5) -- (0,1.5) node [left] {$y$};
   
	% Left wall
	\draw[very thick] (0,-.5) -- (0,.5);

	% First spring (s_0)
	\draw (0,0) -- (0+.25,0);
	\draw (0+.375,-.0125) ellipse (1.25mm and 1.25mm)
				(0+.500,-.0125) node [above,outer sep=2pt,name=s0] {$s_0$} ellipse (1.25mm and 1.25mm)
        (0+.625,-.0125) ellipse (1.25mm and 1.25mm);
	\draw (0+.75,0) -- (0+1,0);
  
	% First two masses and two springs (m_1, s_1, m_2, s_2)
	\foreach \x in {1,2} {
		% Mass (it's just a rectangle)
		\draw ((1.75*\x-.75,0) node[draw,rectangle,name=m\x,anchor=west] {$m_\x$};
		
		% Spring (three circles with connecting lines on the ends).
		\draw (1.75*\x,0) -- (1.75*\x+.25,0);
		\draw (1.75*\x+.375,-.0125) ellipse (1.25mm and 1.25mm)
					(1.75*\x+.500,-.0125) node [above,outer sep=2pt,name=s\x] {$s_\x$} ellipse (1.25mm and 1.25mm)
					(1.75*\x+.625,-.0125) ellipse (1.25mm and 1.25mm);
		\draw (1.75*\x+.75,0) -- (1.75*\x+1,0);
	}
   
   % Ellipses
   \foreach \i in {0,...,2} {
      \path (4.65+\i*.1,0) coordinate (X\i);
      \fill (X\i) circle (1pt);
   }

	% First post-ellipses spring (s_{N-1})
	\draw (5,0) -- (5.25,0);
  \draw (5.375,-.0125) ellipse (1.25mm and 1.25mm)
           (5.500,-.0125) node [above,outer sep=2pt,name=sN-1] {$s_{N-1}$} ellipse (1.25mm and 1.25mm)
           (5.625,-.0125) ellipse (1.25mm and 1.25mm);
	\draw (5.75,0) -- (6,0);
  
	% Last mass and spring (m_n, s_n).
	\foreach \x in {1} {
		% Mass (it's just a rectangle)
		\draw (6,0) node[draw,rectangle,name=mn,anchor=west] {$m_N$};

		% Spring (three circles with connecting lines on the ends).
		\draw (6.8,0) -- (6.8+.25,0);
		\draw (6.8+.375,-.0125) ellipse (1.25mm and 1.25mm)
					(6.8+.500,-.0125) node [above,outer sep=2pt,name=sn] {$s_N$} ellipse (1.25mm and 1.25mm)
					(6.8+.625,-.0125) ellipse (1.25mm and 1.25mm);
		\draw (6.8+.75,0) -- (6.8+1,0);
	}
	\draw[very thick] (7.8,-.5) -- (7.8,.5);

   % The original spring and mass.
%   \draw (0,0)  -- (.25,0);
%   \draw (.375,-.0125) ellipse (1.25mm and 1.25mm)
%            (.500,-.0125) node [above,outer sep=2pt,name=s0] {$s_0$} ellipse (1.25mm and 1.25mm)
%            (.625,-.0125) ellipse (1.25mm and 1.25mm);
%               
%   \draw (.75,0) -- (1,0);
%%   \draw (1,-.25) rectangle (2,.25) (1.5,0) node [name=m0] {$m_0$};
%   \draw (1,0) node[draw,rectangle,name=m0,anchor=west] {$m_0$};
\end{tikzpicture}
\end{center}

% Jeff's picture using LaTeX's native 'picture' environment.
%\begin{picture}(0,0)
%	% A (left) spring and mass. 
%	\newsavebox{\SandM}
%	\savebox{\SandM}(28,10)[bl]{
%		\put(0,5){\line(1,0){8}}
%		\put(8,5){\circle{3}}
%		\put(10,5){\circle{3}}
%		\put(12,5){\circle{3}}
%		\put(12,5){\line(1,0){8}}
%		\put(20,2){\line(0,1){6}}
%		\put(20,2){\line(1,0){8}}
%		\put(20,8){\line(1,0){8}}
%		\put(28,2){\line(0,1){6}}
%	}
%	
%	% Left wall.
%	\put(0,0){\line(0,1){10}}
%	
%	% First two masses.
%	\multiput( 0,0)(28,0){2}{\usebox{\SandM}}
%	\put(56,5){\line(1,0){8}}
%	
%	% Elipses (well, sorta).
%	\put(67,5){\circle{0}}
%	\put(69,5){\circle{0}}
%	\put(71,5){\circle{0}}
%
%	% Last two masses.
%	\multiput(74,0)(28,0){2}{\usebox{\SandM}}
%	\put(130,5){\line(1,0){8}}
%	
%	% Right wall.
%	\put(138,0){\line(0,1){10}}
%	
%	% Springs' and mass' labels.
%	\put(6,15){$s_0$}
%	\put(17,15){$m_0$}
%	
%	\put(33,15){$s_1$}
%	\put(45,15){$m_1$}
%
%	\put(105,15){$s_n$}
%	\put(117,15){$m_n$}
%\end{picture}

Last edited by Singularity on Tue Aug 16, 2011 4:11 am, edited 2 times in total.

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

No Graphics with included File

Post by frabjous »

Try changing:

Code: Select all

\include{SandM.tex}
to simply:

Code: Select all

\include{SandM}
The .tex extension is added automatically.

If it's not that, then post the .log file here.
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Re: No Graphics with included File

Post by Singularity »

That was it.

I added the ".tex" because it wasn't working. I took it away, and now it works. (Obviously, I made some other changes and didn't try them without the ".tex"). Stupid me.

But since I started the thread: How come the graphic is always shown on its own page?
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: No Graphics with included File

Post by frabjous »

The \include command always starts its content on a new page. If you don't want a new page, use \input instead of \include.
Post Reply