General ⇒ Modify file names in a command definition
Modify file names in a command definition
When included, the image file has the same file stem as a the included .tex file (e.g. exclusions.tex and exclusions.jpg).
Rather than pass in both file names, It would be more elegant and less error prone if I could pass a single argument to the new command and generate the file names from that, for example, if I pass in donorItems as a file stem and generate donorItems.tex and donorItems.jpg to use within the command. However, I have not been able to see how this can be done.
Is someone able to suggest a way this might be accomplished, or suggest an alternative way to achieve the same result?
Thank you.
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
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Modify file names in a command definition
Modify file names in a command definition
I believe what you want might be easily possible. However, I didn't really understand your aim. What Do you mean by “generate”? The files themselves should be generated through TeX? Or are they present already but you want to include them? The latter would be as easy asnormanj wrote:for example, if I pass in donorItems as a file stem and generate donorItems.tex and donorItems.jpg to use within the command.
Code: Select all
\newcommand*\myinclude[1]{%
\input{#1.tex}\par
\inlcudegraphics{#1.jpg}%
}
\myinclude{donoritems}
Modify file names in a command definition
Thanks again