3

The command \jobname usually print the file name without the path and extension, so inside a file called foo.tex will print just foo. With pdflatex foo.test or compiling from LaTeXila certainly I obtained this result. But from Gummi what I obtain is .foo.tex

Does anyone know why Gummi compiles differently and how I could get the usual \jobname behavior in Gummi?

Edit: Based on helpful answers of @JosephWright and @Herbert I wonder if it is possible to do the \jobname correction in Gummi only if the source have the .swp extensión or .tex persist in \jobname.

That is, I would like a solution like:

\makeatletter
\let\JobName\jobname
\ifthenelse{\equal{\detokenize{foo}}{\jobname}}
{}
{
\def\@JobName.#1.#2\@nil{#1}
\def\jobname{\expandafter\@JobName\JobName\@nil}
}
\makeatother

This conditional works to check if the jobname is foo or not, but I want a general solution, independent of the file name (not limited to the string foo).

2
  • How robust do you want 'auto-magic to be? For example, might there be multiple . in the file name? Do we need to cope with a hidden file which is not one created by Gummi?
    – Joseph Wright
    Aug 30, 2012 at 18:48
  • @JosephWright, I alway use dots only to mark the extension, so for me is enough that jobname end with .tex or start with . or the source have the .swp extension.
    – Fran
    Aug 30, 2012 at 19:00

2 Answers 2

2

Taking a look at the 'Build Log' I get with a foo.tex test file, it seems Gummi actually compiles .foo.tex.swp, which is hidden on Unix due to the leading ., and which has extension .swp not .tex. So TeX is showing you the correct information. For example, with demo file

\documentclass{article}
\begin{document}
Hello world
\end{document}

saved as foo.tex I get log

This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012)
 \write18 enabled.
entering extended mode
(/home/joseph/Desktop/.foo.tex.swp
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman-x-2012-05-30, ngerman-x-2012-05-30, afrikaans, ancientgreek, ibycus, arabi
c, armenian, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danis
h, dutch, ukenglish, usenglishmax, esperanto, estonian, ethiopic, farsi, finnis
h, french, friulan, galician, german, ngerman, swissgerman, monogreek, greek, h
ungarian, icelandic, assamese, bengali, gujarati, hindi, kannada, malayalam, ma
rathi, oriya, panjabi, tamil, telugu, indonesian, interlingua, irish, italian, 
kurmanji, latin, latvian, lithuanian, mongolian, mongolianlmc, bokmal, nynorsk,
 polish, portuguese, romanian, romansh, russian, sanskrit, serbian, serbianc, s
lovak, slovenian, spanish, swedish, turkish, turkmen, ukrainian, uppersorbian, 
welsh, loaded.
(/usr/local/texlive/2012/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2012/texmf-dist/tex/latex/base/size10.clo))
(/tmp/.foo.tex.aux) [1{/usr/local/texlive/2012/texmf-var/fonts/map/pdftex/updma
p/pdftex.map}] (/tmp/.foo.tex.aux) )</usr/local/texlive/2012/texmf-dist/fonts/t
ype1/public/amsfonts/cm/cmr10.pfb>
Output written on /tmp/.foo.tex.pdf (1 page, 11541 bytes).
SyncTeX written on /tmp/.foo.tex.synctex.gz.
Transcript written on /tmp/.foo.tex.log.

I'm afraid I don't have a solution (other than 'use a different editor'), as there does not seem to be a Gummi setting to alter this behaviour.


The edited question asks for a 'flexible' approach based on Herbert's code. With the restriction that this assumes a simple case (the file name contains only a single . to separate the extension, except if it starts .where Gummi is in use):

\makeatletter
\begingroup
  \def\@jobname#1.#2\q@nil{%
    \ifx\relax#1\relax
      \expandafter\expandafter\expandafter\@@jobname
    \else
      \expandafter\@@@jobname
    \fi
      \jobname\q@nil
  }
  \def\@@jobname.#1.#2\q@nil{#1}
  \def\@@@jobname#1\q@nil{#1}
  \xdef\jobname{\expandafter\@jobname\jobname.\q@nil}
\endgroup
\makeatother
1
  • Works like a charm. I will accept this answer but thanks to @Herbert (upvoted too) . Certainly you're both TeX gurus.
    – Fran
    Aug 30, 2012 at 21:29
3

use in the preamble:

\makeatletter
\let\JobName\jobname
\def\@JobName.#1.#2\@nil{#1}
\def\jobname{\expandafter\@JobName\JobName\@nil}
\makeatother

then \jobname works as usual. The above is only useful for running a file with gummi.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .