Can i write a little function (or macro or whatever) that wraps two commands (functions?) into one; united under a single alias?

Specifically I want to wrap \input{} and \includegraphics{} into a single little entity. So instead of having to:

\input                      {diagrams/TEX/fig1.tex}

I'll be able to just do something like:

\in            {diagrams/TEX/fig1.tex}

It's annoying that we need two remember two different commands to do what is essentially (at a high level/from a user perspective) the same thing, just because of the different file types.

Why? It's just a minor inconvenience, and I understand why it is the way it is, but little things like this are always causing me grief, and I'm all about streamlining my workflow. So I want to build a custom preamble.sty file with this kind of thing in it so I never have to waste time or energy fussing and fatiguing over pedantic little things like the difference between input and include or accidentally typing \include or \inputgraphics, and so on. I like it nice and easy to free my mind to focus on the more important things, like writing content.

Added from comment to question:

Tex is a programming language after all, and abstraction is a basic programming principle. The whole point of LaTeX is supposed to be the ability to focus on content. I'm in pursuit of progress.

  • 2
    Do you know about the ginlctex package? – egreg Jul 8 '19 at 18:22
  • @egreg I'm not familiar, but I'll look into it. – voices Jul 8 '19 at 19:49
  • The distinction between \input and \include is not at all pedantic. However, if you risk to confuse between \includegraphics and \inputgraphics, you will probably also forget the abstract name you give. It's just a question of practice. A graphics object is not \input, because this name is reserved to text files; the similar command \include is mostly a relic of the past, when saving compilation time with big project was essential. Modern machines made it not as useful as it used to be. – egreg Jul 8 '19 at 20:24

From the introduction in the manual of the gincltex package:

This small package builds on the standard LaTeX package graphicx and allows external LaTeX source files to be included like graphic files:


A LaTeX file included this way should result in an identical display as a tightly cropped EPS or PDF image of the same file (apart smaller rounding differences). Usually such files hold a picture environment like picture, pspicture, pgfpicture or tikzpicture, which may take advantage from the standalone class. In fact gincltex is used in newer versions of standalone to seamlessly switch between source and image files.

All options of \includegraphics described in the manual of graphicx (the grfguide) should be supported. Therefore it is possible to resize, rotate and clip the content of the LaTeX source file in the same way as for images.

Thus you just need to do


in your preamble and you can use


You can also define an alias for \includegraphics, for instance


Don't use \in, because it's preempted.

| improve this answer | |
  • but is that what is wanted? I would have thought the ask is to include the .tex file via \input into the normal flow not as a box that is subject to rotation scaling etc. (not that I think it is a good idea to combine the different functions) – Frank Mittelbach Jul 9 '19 at 11:44
  • @FrankMittelbach Judging from the file names, the case seems to point to files containing picture code. – egreg Jul 9 '19 at 11:51
  • maybe I had read it as the text describing things ... but who knows :-) – Frank Mittelbach Jul 9 '19 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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