0

I would like a have a macro that draws a boat. In a .sty file I declared:

\def\bateau{\scalerel*{\includegraphics{/Users/colas/Documents/Maths_2017_2018/Macros/boat.pdf}}{b}}

and put the boat.pdf file in the same directory as the .sty file.

But, if I want to give a .tex file and my macros to someone, this will not work.

How should I do?

Colas
  • 6,772
  • 4
  • 46
  • 96
  • 1
    https://tex.stackexchange.com/questions/1137/where-do-i-place-my-own-sty-or-cls-files-to-make-them-available-to-all-my-te What works for sty and cls files works for images as well. – Johannes_B Dec 03 '17 at 14:46
  • When you consider how difficult it can be to install a .sty file, you might consider using a .tex file with \makeatletter\input{<pathname>}\makeatother. The can be absolute or relative to the current directory. – John Kormylo Dec 03 '17 at 16:35
  • why have the full path in the includegraphics? \includegraphics{boat} should be all that is needed and far more portable. – David Carlisle Dec 03 '17 at 17:29
  • @JohnKormylo why is it easier to install a tex file than a sty file? the search paths are identical. – David Carlisle Dec 03 '17 at 17:31
  • @DavidCarlisle The .sty file is a different directory than the .tex file. And, the boat file is the directory of the .sty file. If I do \includegraphics{boat} it does not work. – Colas Dec 03 '17 at 18:10
  • @Colas then something is wrong or there is something that you are not telling us, if \usepackage{foo} is finding your foo.sty then \includegraphics{boat} should find your boat, the same search path is used. – David Carlisle Dec 03 '17 at 18:18
  • @colas this is why you can use \includegraphics{example-image} as that image file is in the same search path as latex packages and so can be included into any document without specifying any path. – David Carlisle Dec 03 '17 at 18:25
  • Yep I am not using "search paths" but explicit paths to the folder where I put my macros files. Reason: I am not a UNIX guru and never felt comfortable with the "search path". – Colas Dec 03 '17 at 18:57
  • 1
    that is simply wrong sorry. The argument to usepackage is a name not a path. You should use \usepackage{longtable} the fact that on some systems \usepackage{/usr/local/texlive/2017/texmf-dist/tex/latex/tools/longtable} works with only a warning, not an error message is a failing of error checking in the latex system, not something to be exploited. – David Carlisle Dec 03 '17 at 19:15
  • OK Thanks, I will take the time to understand how the "search paths" works and rely on this mechanism. However, I would prefer to add a .xml file to the folder where is the .tex file with some meta info, rather than relying on the TEX install I use and some UNIX things. – Colas Dec 03 '17 at 19:40
  • not sure why you think the path is at all "unix" related. paths are used at the system level and in tex in windows and in msdos before that. Also you probably already have a folder for local packages in your path (~/texmf/tex/latex/...) in texlive, not sure about miktex) – David Carlisle Dec 03 '17 at 20:04
  • @DavidCarlisle - MikTeX at last maintains a database of .sty files. If a .sty file is not in the database, it cannot be loaded using \usepackage. – John Kormylo Dec 04 '17 at 16:45
  • 1
    @JohnKormylo that sounds wrong. are you sure? kpathsea (as used by both miktex and texlive) allows some directories to be searched via the filesystem and and some just by the hashed ls-r files, but this applies to .tex and .sty equally. – David Carlisle Dec 04 '17 at 18:31
  • @JohnKormylo This is wrong. You can add local sty, you only need to update the fndb afterwards if you put it in a texmf tree (and you would have to do it also if you add a tex file in such a place). – Ulrike Fischer Dec 09 '17 at 13:51
  • @UlrikeFischer - Presumably fndb mean filename database. Yes, it is relatively easy to add a file to it, but only if you know it has to be done and how to do it. – John Kormylo Dec 09 '17 at 17:00
  • @JohnKormylo: Sure. Like the \makeatletter/\makeatother part in your part one sometimes need to learn something new to get something working. Where is the problem? – Ulrike Fischer Dec 09 '17 at 17:05
  • @UlrikeFischer - If one thinks using the settings program is easier than typing \makeatletter (assuming it is even needed), more power to them. – John Kormylo Dec 09 '17 at 17:10

0 Answers0