Graphics, Figures & TablesCustom Floats in TOC incorrectly labeled as "Figure"

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
AndyBlue
Posts: 6
Joined: Thu Mar 29, 2018 4:11 am

Custom Floats in TOC incorrectly labeled as "Figure"

Post by AndyBlue »

Dear Honorable Community,

I am formatting my chemistry thesis in Lyx using the ClassicThesis template (which is based on the scrreprt class from KOMA Script). I added a new Schemes float type (see below) to easily provide a way of inserting graphical chemical reaction schemes (via Insert -> Float -> Scheme) However, the captions in the "List of Schemes" in the TOC are all labeled as Figures and not Schemes as shown in the screen shot below,
List of Schemes.png
List of Schemes.png (65.6 KiB) Viewed 8195 times
and I can't determine how to update Lyx to correct this situation.

Here is my MWE:
Infominimal working example
In the local layout:
Format 35
Float
Type scheme
Name scheme
GuiName Scheme Listing
Placement tbp
Extension los
NumberWithin none
Style plain
ListName "List of Schemes"
IsPredefined false
UsesFloatPkg true
floatperchapter true
Entryprefix Scheme
RefPrefix sch
End

In the preamble:
% \usepackage{float}
%\newlistof{listofschemes}{los}{List of Schemes}
\counterwithin{scheme}{section}
\numberwithin{scheme}{chapter}
\usepackage{scrhack}

In the TOC Contents child document:
%*************************
% List of Schemes
%*************************
%\phantomsection
%\addcontentsline{toc}{chapter}{\listschemename}
\listof{scheme}{List of Schemes}
\pdfbookmark[1]\newlistof{listofschemes} %{\listschemename}{los}
[/MWE]

Inserting the "List of Schemes" via the menu option (Insert -> List/TOC -> List of Schemes) will give an empty section. Uncommenting "{\listschemename}{los}" will give me an error message that \listschemename is not defined.

I've tried to follow suggestions in https://tex.stackexchange.com/questions ... sic-thesis and a few other pages but have not been successful in determining the error. Could anybody kindly point me in the correct direction?

Thank you,
Andrew

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Custom Floats in TOC incorrectly labeled as "Figure"

Post by Johannes_B »

Without a minimal working example, it is really hard to help.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
AndyBlue
Posts: 6
Joined: Thu Mar 29, 2018 4:11 am

Custom Floats in TOC incorrectly labeled as "Figure"

Post by AndyBlue »

Thanks for the quick reply, Johannes.
Below is a minimal LaTeX example which I extracted from my master document and which shows "Schemes" mislabeled as "Figures".

Code: Select all

%% LyX 2.3.0 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[twoside,fleqn,american,fontsize=11pt,paper=a4,BCOR=5mm,twoside,openright,cleardoublepage=empty,titlepage,numbers=noenddot,headinclude=true,footinclude=true]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\setcounter{tocdepth}{3}
\PassOptionsToPackage{hyperfootnotes=false,pdfpagelabels}{hyperref}
\usepackage{babel}
\usepackage{float}
\usepackage[unicode=true,pdfusetitle,
 bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=4,
 breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
 {hyperref}
\usepackage{breakurl}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\floatstyle{plain}
\newfloat{scheme}{tbp}{los}
\providecommand{\schemename}{Scheme}
\floatname{scheme}{\protect\schemename}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
% Classic Thesis Style loader
\makeatother
  \input{classicthesis-config-LyX.tex}
\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\counterwithout{footnote}{chapter}
\newlistof{listofschemes}{List of Schemes}
\counterwithin{scheme}{section}
\usepackage{layout}
\numberwithin{scheme}{chapter} 
\usepackage{scrhack}
\makeatother

\usepackage[style=authoryear,backref=true,isbn=false,sorting=nyt,maxbibnames=9]{biblatex}
\begin{document}
\frenchspacing
\raggedbottom
\pagenumbering{roman}
\pagestyle{plain}

%*************************
% Table of Contents
%*************************
\phantomsection
\pdfbookmark[0]{\contentsname}{tableofcontents} 
\setcounter{tocdepth}{2} % <-- 2 includes up to subsections in the ToC 
\setcounter{secnumdepth}{3} % <-- 3 section numbers up to subsubsections 
\manualmark 
\markboth{\spacedlowsmallcaps{\contentsname}}{\spacedlowsmallcaps{\contentsname}} 
\tableofcontents
\automark[section]{chapter} 
\renewcommand{\chaptermark}[1]{\markboth{\spacedlowsmallcaps{#1}}{\spacedlowsmallcaps{#1}}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\enspace\spacedlowsmallcaps{#1}}}

%*************************
% List of Schemes
%*************************
%\phantomsection
%\addcontentsline{toc}{chapter}{\listschemename}
\listof{scheme}{List of Schemes}
\pdfbookmark[1]\newlistof{listofschemes}{\listschemename}{los}
\pagestyle{scrheadings}
Lorem ipsum dolor sit amet.
\begin{scheme}
Consectetur adipiscing elit.
\caption{Retrosynthetic Analysis}
\end{scheme}
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\begin{scheme}
Ut enim ad minim veniam.
\caption{Synthesis of Compound A}
\end{scheme}
\end{document}
In case it is helpful, I'm also pasting the code from the ClassicThesis configuration file (classicthesis-config-LyX.tex) which is referenced in the preamble:

Code: Select all

% ****************************************************************************************************
% classicthesis-config-LyX.tex
% Use it in the preamble of your ClassicThesis.lyx
% ****************************************************************************************************

% ****************************************************************************************************
% 1. Configure classicthesis for your needs here. At some point you will probably want to set 
% "drafting" to false in order to deactivate the time-stamp on the bottom of the pages
% See ClassicThesis.pdf for more information.
% ****************************************************************************************************
\PassOptionsToPackage{
  drafting=false,    % print version information on the bottom of the pages
  tocaligned=false, % the left column of the toc will be aligned (no indentation)
  dottedtoc=false,  % page numbers in ToC flushed right
  parts=true,       % use part division
  eulerchapternumbers=true, % use AMS Euler for chapter font (otherwise Palatino)
  linedheaders=false,       % chaper headers will have line above and beneath
  floatperchapter=true,     % numbering per chapter for all floats (i.e., Figure 1.1)
  eulermath=false,  % use awesome Euler fonts for mathematical formulae (only with pdfLaTeX)
  beramono=true,    % toggle a nice monospaced font (w/ bold)
  palatino=true     % toggle the standard roman font, see end of this file for more suggestions
}{classicthesis}


% ****************************************************************************************************
% 2. Personal data and user ad-hoc commands
% ****************************************************************************************************
\newcommand{\myTitle}{A\xspace}
\newcommand{\mySubtitle}{A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Doctor of Philosophy\xspace}
\newcommand{\myDegree}{Doctor of Philosophy- Organic Chemistry\xspace}
\newcommand{\myName}{B\xspace}
\newcommand{\myProf}{C\xspace}
\newcommand{\myOtherProf}{D\xspace}
\newcommand{\mySupervisor}{Put name here\xspace}
\newcommand{\myFaculty}{F\xspace}
\newcommand{\myDepartment}{Put data here\xspace}
\newcommand{\myUni}{G\xspace}
\newcommand{\myLocation}{H\xspace}
\newcommand{\myTime}{I\xspace}
\newcommand{\myVersion}{First Edition}
% ****************************************************************************************************

% ****************************************************************************************************
% 3. Loading some handy packages
% ****************************************************************************************************
\usepackage{csquotes} % biblatex depends on these
\usepackage{textgreek}

\usepackage{scrhack} % fix warnings when using KOMA with listings package
\usepackage{xspace} % to get the spacing after macros right
\usepackage{mparhack} % get marginpar right
\PassOptionsToPackage{printonlyused,smaller}{acronym}
  \usepackage{acronym} % nice macros for handling all acronyms in the thesis
  %\renewcommand{\bflabel}[1]{{#1}\hfill} % fix the list of acronyms --> no longer working
  %\renewcommand*{\acsfont}[1]{\textsc{#1}} 
  %\renewcommand*{\aclabelfont}[1]{\acsfont{#1}}
  \def\bflabel#1{{\acsfont{#1}\hfill}}
  \def\aclabelfont#1{\acsfont{#1}}
% ****************************************************************************************************

% ****************************************************************************************************
% 4. Setup floats: tables, (sub)figures, and captions
% ****************************************************************************************************
\usepackage{tabularx} % better tables
  \setlength{\extrarowheight}{3pt} % increase table row height
\newcommand{\tableheadline}[1]{\multicolumn{1}{l}{\spacedlowsmallcaps{#1}}}
\usepackage{caption}
% Thanks to cgnieder and Claus Lahiri
% http://tex.stackexchange.com/questions/69349/spacedlowsmallcaps-in-caption-label
% [REMOVED DUE TO OTHER PROBLEMS, SEE ISSUE #82]
%\DeclareCaptionLabelFormat{smallcaps}{\bothIfFirst{#1}{~}\MakeTextLowercase{\textsc{#2}}}
%\captionsetup{font=small,labelformat=smallcaps} % format=hang,
\captionsetup{font=small} % format=hang,
\usepackage{subfig}
% ****************************************************************************************************

% ****************************************************************************************************
% 5. Setup code listings
% ****************************************************************************************************
\usepackage{listings}
%\lstset{emph={trueIndex,root},emphstyle=\color{BlueViolet}}%\underbar} % for special keywords
\lstset{language=[LaTeX]Tex,%C++,
  keywordstyle=\color{RoyalBlue},%\bfseries,
  basicstyle=\small\ttfamily,
  %identifierstyle=\color{NavyBlue},
  commentstyle=\color{Green}\ttfamily,
  stringstyle=\rmfamily,
  numbers=none,%left,%
  numberstyle=\scriptsize,%\tiny
  stepnumber=5,
  numbersep=8pt,
  showstringspaces=false,
  breaklines=true,
  frameround=ftff,
  frame=single,
  belowcaptionskip=.75\baselineskip
  %frame=L
}


% ****************************************************************************************************


% ****************************************************************************************************
% 6. Setup hyperreferences; enable citation backreferences (note: biblatex has its own way)
% ****************************************************************************************************
\PassOptionsToPackage{hyperfootnotes=false,pdfpagelabels}{hyperref}   % backref linktocpage pagebackref
    \usepackage{hyperref}

\hypersetup{%
  %draft, % hyperref's draft mode, for printing see below
  colorlinks=true, linktocpage=true, pdfstartpage=3, pdfstartview=FitV,%
  % uncomment the following line if you want to have black links (e.g., for printing)
  %colorlinks=false, linktocpage=false, pdfstartpage=3, pdfstartview=FitV, pdfborder={0 0 0},%
  breaklinks=true, pdfpagemode=UseNone, pageanchor=true, pdfpagemode=UseOutlines,%
  plainpages=false, bookmarksnumbered, bookmarksopen=true, bookmarksopenlevel=1,%
  hypertexnames=true, pdfhighlight=/O,%nesting=true,%frenchlinks,%
  urlcolor=webbrown, linkcolor=RoyalBlue, citecolor=webgreen, %pagecolor=RoyalBlue,%
  %urlcolor=Black, linkcolor=Black, citecolor=Black, %pagecolor=Black,%
  pdftitle={\myTitle},%
  pdfauthor={\textcopyright\ \myName, \myUni, \myFaculty},%
  pdfsubject={},%
  pdfkeywords={},%
  pdfcreator={},%
  pdfproducer={LaTeX with classicthesis style}%
}

% ********************************************************************
% Setup autoreferences
% ********************************************************************
% There are some issues regarding autorefnames
% http://www.ureader.de/msg/136221647.aspx
% http://www.tex.ac.uk/cgi-bin/texfaq2html?label=latexwords
% you have to redefine the makros for the
% language you use, e.g., american, ngerman
% (as chosen when loading babel/AtBeginDocument)
% ********************************************************************
\makeatletter
\@ifpackageloaded{babel}%
  {%
    \addto\extrasamerican{%
      \renewcommand*{\figureautorefname}{Figure}%
      \renewcommand*{\tableautorefname}{Table}%
      \renewcommand*{\partautorefname}{Part}%
      \renewcommand*{\chapterautorefname}{Chapter}%
      \renewcommand*{\sectionautorefname}{Section}%
      \renewcommand*{\subsectionautorefname}{Section}%
      \renewcommand*{\subsubsectionautorefname}{Section}%
    }%
    \addto\extrasngerman{%
      \renewcommand*{\paragraphautorefname}{Absatz}%
      \renewcommand*{\subparagraphautorefname}{Unterabsatz}%
      \renewcommand*{\footnoteautorefname}{Fu\"snote}%
      \renewcommand*{\FancyVerbLineautorefname}{Zeile}%
      \renewcommand*{\theoremautorefname}{Theorem}%
      \renewcommand*{\appendixautorefname}{Anhang}%
      \renewcommand*{\equationautorefname}{Gleichung}%
      \renewcommand*{\itemautorefname}{Punkt}%
    }%
      % Fix to getting autorefs for subfigures right (thanks to Belinda Vogt for changing the definition)
      \providecommand{\subfigureautorefname}{\figureautorefname}%
    }{\relax}
\makeatother


% ********************************************************************
% 7. Last, but not least...
% ********************************************************************
\usepackage{classicthesis}
\sloppypar

\usepackage[paperwidth=8in,
paperheight=10in,
voffset = -.20in,
bottom = 1in ]{geometry}

% ****************************************************************************************************
Thanks for any guidance you can provide.

Sincerely,
Andrew
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Custom Floats in TOC incorrectly labeled as "Figure"

Post by Johannes_B »

Add \renewcommand{\cftfigpresnum}{Wombat~} right before the list of schemes.

There is a whole bunch of strange code in your example. I am not sure which package should pick up what. The really strangest thing you are using is classicthesis.

Off-topic: I get some errors with your code, this might be due to me still using TeX Live 2017. The undefined commands, at least in part, are in the new LaTeX kernel and don't need a package. But with the code, i don't think you removed the package conciously.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
AndyBlue
Posts: 6
Joined: Thu Mar 29, 2018 4:11 am

Custom Floats in TOC incorrectly labeled as "Figure"

Post by AndyBlue »

It works! It works! It works! It works! Thank you so much, Johannes! I don't think I would ever have figured out your solution. In any case, I quickly replaced "Wombat" with "Scheme" once I realized that Wombat was not an actual LaTeX command (haha).

My document was still getting an error when I generated the master document but I figured out that commenting out the following code, "% \pdfbookmark[1] \newlistof{listofschemes}{\listschemename}{los}" with the percent sign got rid of the error without affecting the List of Schemes.

My document now generates without any errors and it looks very good considering it is still a work in progress. I assume that any strange code is from the classicthesis template although I did enter some customizations to get particular features to look the way I want them to.

Thank you again,
Andrew
Post Reply