Generalinput files with variable filenames

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
lobelt
Posts: 1
Joined: Thu Jul 24, 2025 10:44 am

input files with variable filenames

Post by lobelt »

I want to input a file with a variable filename.
Suppose we have the following files:

foobar.tex
foo123.tex
bar123.tex
foo456.tex
bar456.tex

The files foo123 and foo456 are latex root files and include foobar.tex.
In foobar.tex I want to include bar123 if I compile foo123. When compiling foo456 the file bar456 should be included. And so on.

I started with xstring and tried \StrBehind{\jobname}{foo}. But this gives me an empty string.

My questions are:

How to extract the needed data from \jobname

and

how to build a new filename for using with \input

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply