0

When I try to write a file with some name for example a (then read it afterwards)

\usepackage{fancyvrb}

.........

\begin{VerbatimOut}{a} file content here... \end{VerbatimOut}

% process the file named a

I get a file not found error.

After debugging for a little I realize that VerbatimOut writes to a file named a.tex instead.

The package's documentation fancyvrb-doc only mention VerbatimOut in a single paragraph and no mention of this behavior.

How can I write to a file without extension? (using a different package is fine.)


I'm on an UNIX system so a and a. (empty extension) is different. Compiler is LuaLaTeX (This is LuaHBTeX, Version 1.13.0 (TeX Live 2021/Arch Linux))

user202729
  • 7,143
  • (I don't actually need this, this is only for future searchers (it's completely natural to type a file name as a!). Hopefully they can save some time, or if this is a bug in the package then it can be fixed and they would not encounter it in the first place) – user202729 Nov 01 '21 at 17:28
  • Also I (conveniently) also named the main TeX file a.tex, so I got more hard-to-understand issues. – user202729 Nov 01 '21 at 17:36
  • Actually, reading \openout primitive this is probably inherited from there. – user202729 Nov 01 '21 at 18:11
  • Related: How TeX prioritize file.extension.tex to file.extension if the former exists https://tex.stackexchange.com/q/24773/250119 – user202729 Nov 15 '21 at 03:00

2 Answers2

2

As far as I know, all present implementations of TeX automatically add .tex to file names that lack an extension in the specification, either when opening the file for reading or for writing.

The only “extension-free” implementation I know of was TeXtures, because in MacOS up to version 9 extensions were not used.

So it's essentially impossible to write out a file without an extension in its name.

egreg
  • 1,121,712
1

EDIT

The manual doesn't highlight that

\begin{VerbatimOut}{file}    % creates file.tex

while

\begin{VerbatimOut}{file.txt}  % creates file.txt

Perhaps it should have done so.

I, like you, have tried to get an extensionless output file but have failed

Peter Wilson
  • 28,066
  • I already realized this however, so I decide to ask how to write to extensionless file instead. – user202729 Nov 01 '21 at 18:10
  • @user202729 Apologies, I misread your question. I think that you right about the \openout, used by VerbatimOut, adding a file extension if one is not given. Personally I wouldn't go near trying to change that. BTW, I've always used an extension for every file (perhaps just to remind me what it is about but no extension for a directory, so a directory/file name distinction). – Peter Wilson Nov 01 '21 at 19:17
  • @PeterWilson: \VerbatimOut does nothing special. It is hardcoded in TeX ... – user187802 Nov 26 '21 at 12:07