Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

[UPDATE]

I'm sorry, if my question is less clear. I mean is how to simplify the writing of syntax in main.tex to display images with the same settings,

    \begin{figure}[ht]
    \centering
    \includegraphics{Pictures/pic1.png}
    \caption{Picture 1}
    \label{fig:pic1}
    \end{figure}

with just write, maybe,

    \includegraphics[caption,label]{pic1.png}

[ORIGINAL QUESTION]

I am writing an ebook that contains some of graphics. Some of them generated by code (using TikZ), for example pic1.tex. I think it will be easier to edit if they save in a separated file. I drop all graphics in a folder named Pictures. I named all graphics with the same prefix pic, for example pic2.png, pic3.jpg, etc.

How to include them with a minimal code, say:

    \include{pic1.tex}

Than

    \begin{figure}[h]
    \centering
    \includegraphics{Pictures/pic1.tex}
    \caption{Picture 1}
    \label{fig:pic1}
    \end{figure}
share|improve this question
    
If you don't want/need your graphics to float, you don't need to wrap them in a figure environment. You can just use the includegraphics command, thus saving some typing. Wether that's very useful is another different question :) –  Alberto Miranda Jun 28 '13 at 10:37
1  
\include is for bigger pieces of text and it always emits a \clearpage, so it's definitely not good for such usages; \input is what you're looking for. –  egreg Jun 28 '13 at 10:45
1  
\includegraphics is for embedding driver dependent non-TeX graphic files (Postscript, PDF, PNG, etc.), which are not processed by TeX. TikZ code is TeX code and needs to be digested by TeX. Therefore \inlcudegraphics doesn't work here. –  AlexG Jun 28 '13 at 10:56
    
@AlexG: Oh, I didn't know that includegraphics can't be used for TikZ code ... Thanks! –  Alberto Miranda Jun 28 '13 at 12:31

1 Answer 1

up vote 3 down vote accepted

If you want to be a best practitioner, consider the following. Let your files and folders hierarchy be as follows.

enter image description here

  • main.tex in Project.
  • rules.jpg is in SubDir.
  • behaviors.jpg is in ParentSiblingDir.
% main.tex
\documentclass{article}
\usepackage{graphicx}
\graphicspath{{SubDir/}{../ParentSiblingDir/}}

\newcommand\Insert[5][hbtp]{%
    \begin{figure}[#1]
        \centering
        \includegraphics[#2]{#3}
        \caption{#4}
        \label{#5}
    \end{figure}}


\begin{document}
\Insert{scale=.2}{behaviors}{Students' behaviors}{fig:behaviors}
\Insert{scale=.2}{rules}{Father's rules}{fig:rules}
\end{document}

enter image description here

Remarks:

  • Use \graphicspath to register folders (directories) from which the images will be included or imported. The format is \graphicspath{{<relative path1>}{<relative path2>}{<relative path...>}}. Each path must be followed by /.

  • The remaining code should be clear enough!

share|improve this answer
    
It work! Thanks! –  Edy Jo Jun 30 '13 at 3:06
    
@EdyJo: If you are satisfied with this answer, please accept it by clicking the check mark button (below the down vote button). You can optionally up vote it as well. Terima kasih. –  In PSTricks we trust Jun 30 '13 at 3:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.