Closed nathanaeljsmith2 closed 2 months ago
same for me, win10, current build
I agree with @nathanaeljsmith2. Same thing with my setup:
texstudio.cpp, l. 5355: add File
to absolutPath
:
const QString fn=getRelativeFileName(fi.absoluteFilePath(),rootDir);
This gives the file name including the relative directory path beginning from the tex file folder shown in the side pane: abc/myfile.jpg
. I'm not sure, maybe abc
should not be present.
I'm not sure, maybe
abc
should not be present.
I think it should. If I want to include a file, the subfolder needs to be there. Same for images.
it is a little bit complicated to explain: abc/
is the folder of the tex file to compile, i.e. abc/
is the folder whose files and folders are shown in the side pane. If there is a folder abc/pics
then pics/
should be in the path. I assume that tex won't find the files when adding abc/
.
The problem is in utilsSystem.cpp
(l. 497ff):
QString getRelativeBaseNameToPath(const QString &file, QString basepath, bool baseFile, bool keepSuffix)
{
basepath.replace(QDir::separator(), "/");
if (basepath.endsWith("/")) basepath = basepath.left(basepath.length() - 1);
QFileInfo fi(file);
QString filename = fi.fileName();
QString path = fi.path();
if (path.endsWith("/")) path = path.left(path.length() - 1);
QStringList basedirs = basepath.split("/");
if (baseFile && !basedirs.isEmpty()) basedirs.removeLast();
Var basdir
is the second parameter with value rootDir
set by caller. The value is ok, but last line shown here removes the last/lowest dir from the path (the dir containing the tex file). After that anything in commen is removed from basdirs and dirs. The difference remaining is the dir removed previously and will be added to the output.
I think you can't use getRelativeBaseNameToPath
in this case.
fixed with 04bdbca9ba773dfd1786d4ef2eaf70f989c48a1b
@sunderme your solution inserts the filename (i.e. including suffix). Usually the suffix is missing. Folders are inserted without slash at the end so it is not clear from the text if this is a file or not.
I don't understand. It is a user triggered action, supposedly to put filename/foldername easily into a latex function and that is what is achieved ?
The folder is a special case that my solution implemented, but not necessary (pics/
).
Inserting files: until now used:
\include{subdoc}
and \includegraphics{image}
. For the latter you can define which extension should be used. Those who want to do so need to remove the suffix. But ok, maybe a corner case.
Environment
Expected behavior
Right clicking on a file in the Files tab on the sidebar, and choosing Insert filename, should insert the filename into the document.
Actual behavior
Right clicking on a file in the Files tab on the sidebar, and choosing Insert filename, inserts the folder name into the document.