Texmaker doesn't like filenames with spaces
-
I just installed Texmaker on Windows, and tried to run a build without saving my file. I was greeted with this message:
Being unable to run a build on a file that hasn't been saved makes some sort of sense. Not being able to use a filename with spaces or accents in it?
Can anyone with tex/texlive knowledge explain this?
-
Can anyone with tex/texlive knowledge explain this?
Seems to be TeXmaker specific.
Common newbie mistakes/errors Using TeXmaker
From Version 4.1 onwards,A document must be saved with an extension (and without spaces or accents in the name) before being used by a command
pops out when the file is compiled (Press QuickBuild) before saving it as file-name.tex.
-
It's not tex's fault. It works fine with spaces in the filename, I just tested it. Likely the people who made Texmaker just did something like
system("tex " + filename)
instead of spawning the process the proper way, saw that it choked on spaces, and decided to put in an error message rather than do it properly.
-
For fuck's sake.
-
I went and had a look at Texmaker's source code. Theory confirmed. In
TexMaker::RunCommand
intexmaker.cpp
:proc = new QProcess( this ); proc->setWorkingDirectory(fi.absolutePath()); proc->setProperty("command",commandline);
More , checking if a file has been saved:
if (finame.startsWith("untitled")) { QMessageBox::warning( this,tr("Error"),tr("A document must be saved with an extension (and without spaces or accents in the name) before being used by a command.")); return; }
Holy hell.
-
So, saving a file as
untitled_data_description.tex
would do... what?
-
#
Holy shit.Weird, saving my file as "untitled.tex" seems to work. Maybe that check is old code that wasn't removed?
-
I don't know why I've gone through the trouble to figure it out, but I did. (This codebase is ridiculous, by the way.)
finame
is an absolute path, except when the file has not been saved, then it'suntitled<n>
. So it works.And why is this so? Well, you can have multiple files open. The UI displays a list of files in a dropdown menu. But what do you do with a new document, which doesn't have a filename yet? Simple, you do this:
filenames.insert( edit, "untitled"+QString::number(untitled_id) );
If a file is actually saved or loaded, the absolute path is used, and the dropdown lists only the part after the last
/
. And then, to see if there is actually a file on the disk or not, you test the start of the string against"untitled"
! Since an absolute path doesn't start withuntitled
, it works. Of course, this "logic" is scattered across the codebase.
-
Nobody has pointed out one of the biggest WTFs...
"saved with an extension".
Why do you care if it has an extension or not, it's not like it changes the file contents!
-
Uh oh, don't get that one started again.
-
I mean, I'm agnostic of that whole argument. But a program refusing to behave without a file extension is just silly.
-
What's weird is that all that ery suggests a terribly written piece of software that should fall apart at a touch, and I 've been using it without a problem for like 4 years.
Even though I've already met and accommodated myself to the real WTF in there. There's this setting:
And there's the Quick Build setting: a series of command lines separated with the pipe symbol:
And because I want to use TeXMaker's built-in PDF viewer in my custom build command, I have to paste in the path to Adobe Reader.
-
What's weird is that all that ery suggests a terribly written piece of software that should fall apart at a touch, and I 've been using it without a problem for like 4 years.
In 4 years, you've never tried to save a file with a space in it? Do you just pre-emptively name your files with dashes or underscores, on the assumption all the software you use is shitty? Or...
-
I like dashes.
-
I like applications that don't add ADDITIONAL limitations to the already insanely-limited number of characters I can use in filenames.
Wanna hear about how Mac Classic allowed LITERALLY EVERY CHARACTER EXCEPT COLON? Even slashes? BOTH TYPES OF SLASHES? Because I can talk about Mac Classic, buddy.
-
Interesting! It seems they use QProcess but rely on the undocumented behaviour of
setProperty
from QObject andcommand
to fuck with Qt's OO design, and to secure a spot in TD !
String is the best type after all, who needs methods.
-
Wanna hear about how Mac Classic
Tell me about it
Mac Classic allowed LITERALLY EVERY CHARACTER EXCEPT COLON?
Why not I want my colon in there, I have it examined with doctor and it is fine.Because I can talk about Mac Classic, buddy.
You do?
-
I agree with your sentiment, but they way you're going about spreading it makes me want to flag this as off-topic.
-
You should totally go for that.
-
Theory confirmed.
Sounds like it was some horrible badly coded hack to start out with, then badly converted to use
QProcess
. It's the paint-over-the-mold approach!
-
Do you just pre-emptively name your files with dashes or underscores, on the assumption all the software you use is shitty?
I do. Over the years though I have grown to dislike the look of spaces in filenames anyway.
-
You are irreversibly corrupted. You are no longer allowed to work on computer user interfaces.
-
Do you want an even worse WTF? See that Quick Build setting? Do you want to know what it actually does with that string? Among other things, it does this:
if ( (pdflatex_command.contains("synctex=1")) || (latex_command.contains("synctex=1")) || (xelatex_command.contains("synctex=1")) ) pdfviewerWidget->jumpToPdfFromSource(getName(),currentline);
And there are more of those too. This is all in that one
RunCommand
function I mentioned earlier. It's absolutely horrible. Also, I added the formatting myself, they have it all on one long line and it's hard to see what's going on.
-
Wanna hear about how Mac Classic allowed LITERALLY EVERY CHARACTER EXCEPT COLON? Even slashes? BOTH TYPES OF SLASHES? Because I can talk about Mac Classic, buddy.
Naw, I'd rather hear about how Linux allows LITERALLY EVERY CHARACTER EXCEPT SLASH. Even colon. AND BACKSLASH. Because I know you can talk about that, too.
-
-
And carriage return, and BELL.
Exactly! That's flexibility!
It's just a shame that no filesystem in common use will let me save
TPS Report 8/2/2016 12:59.doc
-
And \0.
-
In 4 years, you've never tried to save a file starting with a space
in it? were you forced to use CLI to make files starting with dot?FTFY
-
Use Google Drive, it is in common use and I just created a doc named
TPS Report 8/2/2016 12:59.doc
-
I can save a file with that name on Google Drive.
Edit: It doesn't like the
/
-
Edit: It doesn't like the /
Lies!
It might plausibly have trouble syncing that file with a local cache, but that would be because the local filesystem is retarded.
-
It's just a shame that no filesystem in common use will let me save
TPS Report 8/2/2016 12:59.doc
Because writing dates with slashes is sick, that's why!!111
But if you insist,TPS Report 8∕2∕2016 12:59.doc
would work (for suitable values of "work").
-
Nonsense.
TPS Report 0.00198412698412698412698412698413 12:59.doc
is entirely not the same thing.
-
It's true that none of my tex filenames contain spaces, dashes, capital or
accented letters. This is for two reasons:
3. TeX and friends are ancient software and yes, I took on this habit
because let's play on the safe side.
12. More often than not I find myself wanting to do stuff not possible in
the GUI abstraction and go to the command line. Much faster to type
bscthesis.tex
then"A Novel Solution To Synergistic Frobnication Of R2-D2 Widgets.tex"
-
You are irreversibly corrupted. You are no longer allowed to work on computer user interfaces.
-
Much faster to type
bscthesis.tex
then"A Novel Solution To Synergistic Frobnication Of R2-D2 Widgets.tex"
There are still shells around without TAB completion for filenames?!
-
Tab completion is a significant improvement to CLI usability. Therefore it can't possibly exist. QED.
-
You are irreversibly corrupted. You are no longer allowed to work on computer user interfaces.
I'm not stupid, I always make sure my code works with spaces in the path and I don't chastise users for having different opinions than me ;)
-
-
A Novel Solution To Synergistic Frobnication Of R2-D2 Widgets
Bosh. If it's so novel, why isn't it patented?
-
There are still shells around without TAB completion for filenames?!
I'm too lazy to check, but I bet Shelldon Cooper doesn't support it.
Filed under: I bet if I check that's a real shell
-
When are you going to start railing on programming languages that don't let you use identifiers like "The users's date of birth" or "tax paid FY 2015/2016" or "class"?
Or programming languages that require you to type on the keyboard to enter code? Oh noes! What a terrible UI!
-
Oh shut up.
-
It would be nice if I didn't have to type to program…
-
-
-
Looks like Texmaker is actually perfectly fine with filenames containing spaces. The template command:
latex -interaction=nonstopmode %.tex
gets processed in part with
QRegExp rx2("(%+)"); capt=""; if (rx2.indexIn(commandline) != -1) capt=rx2.cap(1); if (capt=="%") commandline.replace("%","\""+basename+"\""); else if (capt=="%%") commandline.replace("%%","%");
to correclty quote the filename. Filenames with accents work, too.
So, the error message is the . As is the -style parsing with regex, the automatic replacement of the file's extension with ".tex" for no reason, the atrocious code formatting, half the lines consisting of commented-out old code, ...
-
-
Defense in Depth gone horribly awry (we don't trust our code to escape spaces, so we'll just ban them anyways)?
-
And carriage return, and BELL
...and does it actually make the sound when listing files with bell in name?