0

If I have a PDF file whose name is <\jobname>~[solved].pdf (with spaces in the absolute path and the file name), how can I create a TeXStudio user command that opens this file knowing that the following doesn't work in recognizing the intended full name:

"C:\Program Files\SumatraPDF\SumatraPDF.exe" -reuse-instance -inverse-search "\"C:/Program Files (x86)/texstudio/texstudio.exe\" \"%%f\" -line %%l" "?am [solved].pdf"

Diaa
  • 9,599

1 Answers1

1

I have found the solution after some experimentation.

If the output PDF file is prefixed by a word [solved] and space (i.e. [solved]~<\jobname>.pdf), the command should be

"C:\Program Files\SumatraPDF\SumatraPDF.exe" -reuse-instance -inverse-search ""C:/Program Files (x86)/texstudio/texstudio.exe" "%%f" -line %%l" ?a"[solved]" ?m.pdf

On the other hand, if it is appended by a space and a word [solved] (i.e. <\jobname>~[solved].pdf), the command should be

"C:\Program Files\SumatraPDF\SumatraPDF.exe" -reuse-instance -inverse-search ""C:/Program Files (x86)/texstudio/texstudio.exe" "%%f" -line %%l" "?am ?"[solved]".pdf"

The key note here is to understand that a space is a terminating character, which needs to have a following ? in order to use further selectors/pathname parts/terminating characters.


For TeXstudio v3.0, unknowingly, the syntax of the first case has to be slightly modified to be

"C:\Program Files\SumatraPDF\SumatraPDF.exe" -reuse-instance -inverse-search ""C:/Program Files (x86)/texstudio/texstudio.exe" "%%f" -line %%l" ?a"[solved]" "?m".pdf

enter image description here

Diaa
  • 9,599
  • "C:\Program Files\SumatraPDF\SumatraPDF.exe" -reuse-instance -inverse-search ""C:/Program Files (x86)/texstudio/texstudio.exe" "%%f" -line %%l" ?a [Exam]" ?m.pdf" – Diaa Sep 11 '20 at 18:11
  • "C:\Program Files\SumatraPDF\SumatraPDF.exe" -reuse-instance -inverse-search ""C:/Program Files (x86)/texstudio/texstudio.exe" "%%f" -line %%l" ?a [Exam]" "?m".pdf – Diaa Sep 11 '20 at 18:11
  • ) is a terminating character for the selector ?. So, it should be "C:\Program Files\SumatraPDF\SumatraPDF.exe" "?a)[Exam] ?m.pdf" – Diaa Sep 13 '20 at 12:38
  • texfot −−quiet lualatex -synctex=1 -interaction=nonstopmode -shell-escape "\AtBeginDocument{\printanswersfalse}\input{%}" then call another user command to rename cmd.exe /C ren "?am.pdf" "[Exam] ?m.pdf". Check this for texfot and this for calling the command prompt. – Diaa Oct 09 '20 at 23:39
  • All the info in this file. – Diaa Oct 29 '20 at 23:24