0

I am using currfile package to get the file name. My file name has the form

"code blah blah blah.tex"

what is being displayed is

"code_blah_blah_blah.tex"

How can I remove the underscores?

Here is the code

\documentclass[twoside,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{babel}
\usepackage[unicode=true,pdfusetitle,
 bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
 breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
 {hyperref}

\makeatletter

\usepackage[T1]{fontenc}
\usepackage{currfile}

\newcommand{\fileName}{\currfilebase}

\pagestyle{fancy}
\fancyhf{}
\lhead{\fileName}

\makeatother

\begin{document}
  Test
\end{document}

Here is the output

Output

  • An example, please. – egreg Jul 15 '16 at 8:53
  • 3
    is it really an underscore or the verbatim visible space character (which has short uprights at either end) – David Carlisle Jul 15 '16 at 9:09
  • There are no underscores in my output: i.imgur.com/MQXAxTP.png – alwaysask Jul 15 '16 at 9:14
  • 1
    No, there is not. At least not in the output on my machine. Did you clicked the link I gave you above? Where do you see the underscores? Even copying the text from pdf reveal no underscore. Please show us the output on your machine (edit your question and add it there). – alwaysask Jul 15 '16 at 9:28
  • 1
    texlive returns the filename surrounded by quotes if there are spaces, so I can not reproduce. Can you add \typeout{JOBNAME=\jobname} to your document, and show the log output from that, I get JOBNAME="aaa bbb ccc" from a file called aaa bbb ccc.tex – David Carlisle Jul 15 '16 at 11:31
1

This MWE works for me:

\documentclass[twoside,english]{article}
\usepackage[T1]{fontenc}
 %\usepackage[latin9]{inputenc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{babel}
\usepackage[unicode=true,pdfusetitle,
bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
{hyperref}
\usepackage{currfile}
\usepackage{xstring}

\newcommand{\fileName}{\currfilebase}

\pagestyle{fancy}
\fancyhf{}
\lhead{\StrSubstitute{\fileName}{"}{}}

\begin{document}
    Test
\end{document}

Output:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.