Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

latexteada
latexteada

Posted on

     

LaTeX: The include Command

Hello, how are you? :)

In this post I talk about

  • The\include command

Introduction

The last posts of this blog have been aboutMacros we have checked some variants of macros and we have seen that these are declared in the preamble of our document, so, if we want to declare a new macros we must go to the preamble, declare them there and then go back to our document, everything is fine.

But what happens if we need to declare the same macros in another document, and in another and so on, it will be a headache because we need to declare them in each document that we create. There must be an easy way to do it, and this is the main topic, or purpose, of this post is to teach you a very useful instruction, the\include command

Theinclude command

Here we are going to use this command to include the macros and other environments that we will see in the following posts, but this command has another functionalities, which are not related with this topic

  • This command is declared in the preamble

As its name suggest itincludes the content of other.tex (The extension of theLaTeX document) document into our current document, the command is simple

\include{pathOfFile/nameOfFile}
Enter fullscreen modeExit fullscreen mode

Including a file withinclude

Do not forget to add the extension of the file, in this case, it is.tex If you do not add it you will get an error

We have seen that the command to include a file is\include{} but we need to give thepathOfFile it is thelocation of our file that we want to import to our current file, and there are three possibilities

  • File in the same location where we are working We just need to put the name of the file
\include{myFile.tex}
Enter fullscreen modeExit fullscreen mode
  • File in the same location but inside another folder We need to put the route to the file, indicating the name of the folder in the path.

Let's suppose my folder's name ismyFolder

\include{myFolder/myFile.tex}
Enter fullscreen modeExit fullscreen mode

If it is inside multiple folders we just put the name of all the folders where it is and then the name of the file

\include{myFolder/.../myFile.tex}
Enter fullscreen modeExit fullscreen mode

Where the... is the short for all the folders, but youmust put the name of all the folders

  • File in a different location Here we need to put the specific route where the file is. In the last point we see that to godeeper we need to put the name of the folders, now to gobackward we need to use..
\include{../myFolder/myFile.tex}
Enter fullscreen modeExit fullscreen mode

This is all for today, thanks

Do not forget to follow me on twitter@latexteada

Greetings :)

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Hello, this is where I am going to give some base briefs of LaTeX
  • Location
    México
  • Work
    Student
  • Joined

More fromlatexteada

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp