# How to show label names on list of custom floats created with \float package and using custom document formats, as the abntex2, from brazil

I am formatting my thesis document and I am having some trouble with custom floats lists.

I need to get a list of custom floats, that represent charts, to have their labels printed as showed in the example below.

However, I am getting the format as shown below.

I am using this commands to create the new float with the 'float' package:

\usepackage{float}
\newfloat{chart}{thp}{lochart}
\floatname{chart}{Chart}


Moreover, I am also using this command to print the custom list:

\renewcommand{\figurename}{Chart}
\listof{chart}{List of charts}


I am using it because of what was advised in the thread: Formatting list of custom floats in classic thesis

My main problem is that LaTeX is not easy to use and has lots of ambiguous commands provided by packages that people think help when creating stuff.

The point is that all packages I tried are too over complicated to use and usually rename basic commands, or sequence of them. Consequently, when trying to change simple stuff with basic LaTeX commands and interfaces it appears to be impossible if you are yet learning, as I am, to customize it properly.

Despite that, I also tried creating a custom list by hand.

I appreciate any help of yours.

• As long your caption setup does not know that it should use Chart as prefix to your chart numbers, why should it print it then? Apparently abntex2 (which is a class not recommended here on TeX.SE by some of our Brazilian users) or some other package changes the caption settings for table however such that Table ... appears – user31729 Feb 4 '18 at 19:13
• I removed the irrelevant tags labels and thesis by the way. – user31729 Feb 4 '18 at 19:15
• All chart labels are being displayed correctly in the text. They are not showing only when printing the list. I am checking the caption setup as you also said. I am quite new to latex and do not know much about its setup yet, just how to write using some commands. Yes, probably the abntex2 is changing their setup so they are being displayed but I do not know which one, where, and the flag that it changed. – Mr. Silva Feb 4 '18 at 19:30
• I do not like to use the abntex2, as you mentioned that package is not recommended and I do not recommend it either, since it can mess with your document structure and with other packages. However, Brazilian universities demand some national standards that are quite painful to configure by hand and that the abntex do it for us. Nevertheless, I have solved the problem with your advice by using the commands to change the caption settings. – Mr. Silva Feb 4 '18 at 20:17
• @Mr.Silva: Perhaps you should post a compilable version of your achievements as a self-answer, such that other users with the same problem can use it as well – user31729 Feb 4 '18 at 21:09

If you had taken a look at the project site, there is a Wiki with a specific entry:

https://github.com/abntex/abntex2/wiki/HowToCriarNovoAmbienteListing

% Novo list of (listings) para QUADROS

% configurações para atender às regras da ABNT



Want a MWE?

\documentclass{abntex2}

% Novo list of (listings) para QUADROS

% configurações para atender às regras da ABNT

\begin{document}

\begin{tabular}{|ccc|}
\hline
a & b & c\\
a & b & c\\
a & b & c\\
a & b & c\\
\hline
\end{tabular}

\end{document}

• Yor MWE is not working on my source code due to the syntax of the line \newfloat[chapter]{quadro}{loq}{\quadroname}. I am not sure why but what worked for me was \newfloat{quadro}{}{loq} – Mr. Silva Feb 5 '18 at 16:31
• Sure, if you don't show us your "source code" (see tex.meta.stackexchange.com/questions/3300/…), we can just guess... – Joseph Feb 5 '18 at 18:48

It can be a pain to deal with lists, custom lists, and custom floats since I believe LaTex syntax is not as straightforward or comfortable to read and understand, for beginners like me, as some other mainstream languages are.

According to @Joseph and @Christian, that problem could be solved by creating custom environments or even changing some caption options and they are quite right. However, the presented syntax by @Joseph, and available at https://github.com/abntex/abntex2/wiki/HowToCriarNovoAmbienteListing, did not work at first attempt.

So I wanna share my experience in order to help those with similar problems. Just to remember, the main problem is that the labels were not being displayed when printing a 'listof' contents as depicted below.

To solve that, printing both labels and their correct counter value, I tried two approaches where both successfully solved the problem.

before applying any of the solutions you should be aware that I am assuming you wanna create a custom float and display it, its caption, and listing names correctly.

For this to work, a custom float needs to be created with de commands:

\usepackage{float}
\newfloat{chart}{}{locharts}
\floatname{chart}{Chart}


The first one will import your float package and the second one will create a new float called 'chart', the first parameter, and it will store it in a list file called 'locharts', last parameter. The middle {} is responsible to hold the float format option. For this example, you can leave it in blank since I do not want any special options for that right now. Finally, the command \floatname is just defining that the recently created float should be called 'Chart' with a capital letter.

After creating your custom float you can use two approaches, that I provide here, to change the label names when displaying the list.

For the first approach, you should use the code below.

%CREATE A NEW COMMAND TO HOLD THE LIST FILE NAME SO YOU CAN HANDLE AND MODIFY IT
\newcommand{\listofchartsname}{List of charts}

%CREATE THE LIST
\newlistof{listofcharts}{locharts}{\listofchartsname}

%INSERT AN ENTRY
\newlistentry{chart}{locharts}{0}

%CHANGE THE LIST DISPLAY NAMES
\counterwithout{chart}{chapter}

%CHANGE HOW THINGS WILL BE PRINTED
\renewcommand{\cftchartname}{Chart\space}
\renewcommand*{\cftchartaftersnum}{\hfill--\hfill}


What I believe to be important here is the fact that you are creating a command with \newcommand{\listofchartsname}{List of charts} to hold a variable name called 'List of charts'. That variable is then used to give a name to your list with the command \newlistof{listofcharts}{locharts}{\listofchartsname}. After that, \counterwithout{chart}{chapter} is being used to specify not to count chapters when incrementing your float counter.


\newlistof{listofcharts}{locharts}{\listofchartsname}


The results of manipulating, creating, a custom float with this approach is depicted in the Fig. bellow

which was produced by calling

\pdfbookmark[0]{\listofchartsname}{locharts}
\listofcharts*


Differently, the second approach is based on caption options, as suggested by @Christian. Before going to that I wanna share this link: https://mirror.hmc.edu/ctan/macros/latex/contrib/caption/caption-eng.pdf. It is the documentation of the 'caption' package that describes ways on how to customize your captions and listing options for them.

In order to use this second approach you only need to use the code

\usepackage[labelfont=bf, textfont=bf]{caption}
\DeclareCaptionListFormat{chartListFormat}{\hspace*{-30.5pt}Chart #2~--~}
\captionsetup[chart]{listformat=chartListFormat}


where the command \usepackage[labelfont=bf, textfont=bf]{caption}, for this example, is importing the package 'caption', to handle them in an easy way. The options 'labelfont=bf' and 'textfont=bf' are just specifying that both fonts, from all my captions labels and counter, should be boldly printed.

In order to change how labels will be shown when listing you need to change the caption listing format with the option 'listformat'. Among many approaches, this can be accomplished by creating a custom listing format with the command \DeclareCaptionListFormat{chartListFormat}{\hspace*{-30.5pt}Chart #2~--~}, where 'chartListFormat' is its name, \hspace*{-30.5pt} being some space to avoid things to get overlapped, and 'Chart #2~--~' being a string telling that it should print the name Chart followed by the #2, a parameter, that indicates the current counter value for one float from the list (this command is called for each element on the created floats list).

To set that options, the command \captionsetup[chart]{listformat=chartListFormat} can be used and it is specifying the option 'listformat=chartListFormat' for the custom float 'chart' that was created. This approach will lead to a list as shown below

which was produced by calling

\listof{chart}{Charts list}


I hope that those methods could help any of you that is having some trouble configuring captions for custom printing or when just configuring captions. I wanna also share this link: http://www.peteryu.ca/tutorials/publishing/latex_captions. It contains some good examples of how to customize your captions.

• Mr. Silva, this might have worked for you, but it's more complicated than the "official" abntex2 Wiki suggestion, and uses some of the same commands. You also didn't specify why the other answer didn't work out for you, since the MWE compiles fine and you didn't provide a MWE in your answer. The memoir class already provides the functionalities of the packages caption and float. There is a package, newfloat, which allows you to create a custom new float with a list with one command. Adapting those to ABNT rules, as the saying goes, "são outros 500". – Joseph Feb 5 '18 at 11:36
• It is the same MWE from the abntex2 page just changed the syntax for float creation. It has more text and that may be turning it complicated to read. You do not need to import them. Just provided a self-contained example. I will try that newfloat package too. – Mr. Silva Feb 5 '18 at 16:54
• Never mind, without you showing a MWE, your own solution won't be of any use for other people. – Joseph Feb 5 '18 at 18:51