3

I would like to define a new set of labels for my pictures like this:

\usepackage{newfloat}
\DeclareFloatingEnvironment[listname={Seznam grafů}]{Graf}

However, latex refuses to recognize "ů" in the package option and throws an error on me:

! Package inputenc Error: Keyboard character used is undefined

Minimal working example is this:

\documentclass[12pt,a4paper]{article}\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[english,czech]{babel}
\usepackage[nottoc]{tocbibind}
\usepackage{newfloat}
\DeclareFloatingEnvironment[listname={Seznam grafů}]{Graf}
\begin{document}

\tableofcontents


\listoffigures
\listofGrafs
\end{document}

The first compilation works, but then it fails on second compilation, as the generated .toc file is causing trouble (so this is similar to Problem with special characters in .toc files but the accepted solution there does not help as I specify inputenc early enough). The generated .toc file goes like this:

\select@language {czech}
\contentsline {section}{Seznam obr\'azk\r {u}}{1}
\contentsline {section}{Seznam graf·}{1}

If I replace · with \r {u}}, the next compilation goes fine and a latex document with a TOC is generated, but I would have to do it before each compilation, wihch is not handy. Using \r{u} like this:

\DeclareFloatingEnvironment[listname={Seznam graf\r{u}}]{Graf}

does not help.

Update: This has since been resolved: http://sourceforge.net/p/latex-caption/tickets/22/ (as of 16.09.2015, the bug should be uploaded to CTAN on 20.09.2015 - expect some time until it trickles down to your distribution)

  • 1
    You can use the “long form”: graf\r{u}. Can you supply a minimal example? In my experiment I have no problem even with Seznam grafů – egreg Jun 14 '15 at 16:24
  • I do not see any ů in the package options. The package options in the question are utf8, english, and czech, plain ASCII strings, limited to letters and digits. – Heiko Oberdiek Jun 14 '15 at 16:44
  • Also the inputenc error message is quite inconsistent with option utf8. The error message would be Unicode char ... not setup for use with LaTeX. The option of inputenc is different, not utf8, and the input encoding name would have been shown in the second line of the error message Keyboard character used is undefined\\in inputencoding `...'. – Heiko Oberdiek Jun 14 '15 at 16:50
  • I expanded the question and added a MWE. Using \r{u} does not help. The problem is in the toc file that gets generated. – sup Jun 15 '15 at 15:28
3

The newfloat package does a bunch of \edef when it should use, at least in some of those cases, \protected@edef.

You can solve the issue doing an indirect passage:

\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,czech]{babel}
\usepackage{lmodern}
\usepackage[nottoc]{tocbibind}
\usepackage{newfloat}
\protected\def\listGrafsname{Seznam grafů}
\DeclareFloatingEnvironment[listname={\listGrafsname}]{Graf}

\begin{document}

\tableofcontents

\listoffigures
\listofGrafs
\end{document}

The macro \listGrafsname will thus pass through any \edef unmodified.

For hyperref you have to add another piece of information:

\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,czech]{babel}
\usepackage{lmodern}
\usepackage[nottoc]{tocbibind}
\usepackage{newfloat}
\usepackage[unicode]{hyperref}

\protected\def\listGrafsname{Seznam grafů}
\DeclareFloatingEnvironment[listname={\listGrafsname}]{Graf}
\pdfstringdefDisableCommands{\def\listGrafsname{Seznam grafů}}

\begin{document}

\tableofcontents

\listoffigures
\listofGrafs
\end{document}
  • Great, this fixes my problem thanks! Should I report it as a bug to the creators of the newfloat package? – sup Jun 15 '15 at 16:13
  • BTW: I also use hyperref, it now complains like this: Package hyperref Warning: Token not allowed in a PDF string (Unicode): (hyperref) removing \listGrafsname' on input line 317. but it does not seem that it changes anything. Any idea what the warning means? – sup Jun 15 '15 at 16:52
  • 1
    @sup I added the workaround for hyperref – egreg Jun 15 '15 at 17:10
  • How would I input \DeclareFloatingEnvironment[listname={\listGrafsname}]{Graf č.} (note the "Graf č." instead of "Graf" as in the original answer? – sup Jul 19 '15 at 14:31
  • 1
    @sup The argument is just a string that's used to define the file extension of the auxiliary file. Use ASCII characters in it – egreg Jul 19 '15 at 21:19

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.