Code Monkey home page Code Monkey logo

Comments (28)

1marc1 avatar 1marc1 commented on August 20, 2024 41

Agreed: we need the ability to have a table of tables and a table of figures that works in much the same way as a table of contents.

Perhaps something like:
:toc:
:tot:
:tof:

Marc.

from asciidoctor-extensions-lab.

znerd avatar znerd commented on August 20, 2024 12

It would be nice if the concept could be expanded to any kind of list.

E.g. I have a document that contains requirements. It would be nice if I can list all the requirements in a Requirements Index appendix, with references to the location of the requirements.

from asciidoctor-extensions-lab.

Alwinator avatar Alwinator commented on August 20, 2024 4

No problem :)
You can find my new extension here: https://github.com/Alwinator/asciidoctor-lists

from asciidoctor-extensions-lab.

mojavelinux avatar mojavelinux commented on August 20, 2024 2

which assumes that the person using Asciidoctor is also a (Ruby) programmer, which might not always be the case

I understand that. But you have the freedom to hire someone to do what you want. So my point still stands. I volunteer to work on this, so I do what I'm willing to do.

from asciidoctor-extensions-lab.

ggrossetie avatar ggrossetie commented on August 20, 2024 2

@Alwinator you can use the "contrib releases" topic in the #annouce stream: https://asciidoctor.zulipchat.com/#narrow/stream/279652-announce.C2.A0.F0.9F.93.A2/topic/contrib.20releases

from asciidoctor-extensions-lab.

GeniusWaxer avatar GeniusWaxer commented on August 20, 2024 1

I would like to have this feature as well.

As of now I've found a workaround where I create a counter for the figures and lists respectively and set the id of them to Figure-{counter:image-number} and Table-{counter:table-number}.
The list of figures can then be created manually by using <<Figure-1, Figure 1>><<Figure-1>>

Ex:

= My AsciiDoc
:counter: image-counter: 0
:counter: table-number: 0

image::image001.png[title="My Image", id="Figure-{counter:image-number}"]

[title="My table", id="Table-{counter:table-number}", options="header"]
|===
|Col 1            | Col 2
|Row 1 Cell 1     | Row 1 Cell 2
|Row 2 Cell 1     | Row 2 Cell 2
|===

== List of Figures

<<Figure-1, Figure 1>><<Figure-1>>

== List of Tables

<<Table-1, Table 1>><<Table-1>>

Which should render similar to this:

My AsciiDoc

My Image
Figure 1. My Image

Col 1 Col 2
Row 1 Cell 1 Row 1 Cell 2
Row 2 Cell 1 Row 2 Cell 2

Table 1. My Table

List of Figures

[Figure 1 My Image](#My Image)

List of Tables

[Table 1 My Table](#My Table)

NOTE: The counters can NOT be named figure-number and table-number since those two counters already exists for the automatic numbering of figures and tables.

Hope this helps for now.

from asciidoctor-extensions-lab.

mojavelinux avatar mojavelinux commented on August 20, 2024 1

I think this issue needs to be moved to the extensions lab. It's not specifically related to Asciidoctor PDF. If the extension generates a section with references and adds it to the parsed document, the converter will add that output. And then you can include it regardless of output format.

from asciidoctor-extensions-lab.

mojavelinux avatar mojavelinux commented on August 20, 2024 1

Since this became a community extension, I'm going to close this issue as there is no reason to duplicate it here.

See https://github.com/Alwinator/asciidoctor-lists

from asciidoctor-extensions-lab.

igagis avatar igagis commented on August 20, 2024

Unfortunately, looks like there's no way to have also page numbers in the lists of tables and figures, but good workaround for now.

from asciidoctor-extensions-lab.

GeekMustHave avatar GeekMustHave commented on August 20, 2024

I also would like to vote for this feature to be added to ASCIIDoctor.

My comrades who use Word keep poking me about this. "We can do it, you can't"

from asciidoctor-extensions-lab.

mojavelinux avatar mojavelinux commented on August 20, 2024

My comrades who use Word keep poking me about this. "We can do it, you can't"

They would be wrong. You can do just about anything in Asciidoctor. Sometimes, it just takes some custom programming. Something Word does not have. We win in that argument every time ;)

All we are talking about here is out of the box behavior.

from asciidoctor-extensions-lab.

GeekMustHave avatar GeekMustHave commented on August 20, 2024

Preaching to the choir.... I see good things in the future for ASCIIDoctor

On Wed, Oct 5, 2016 at 3:40 PM, Dan Allen [email protected] wrote:

My comrades who use Word keep poking me about this. "We can do it, you
can't"

They would be wrong. You can do just about anything in Asciidoctor.
Sometimes, it just takes some custom programming. Something Word does not
have. We win in that argument every time ;)

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/asciidoctor/asciidoctor-pdf/issues/456#issuecomment-251777247,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AOZQQXesPf65rMxO0iIjDdS9Ft9Y_b41ks5qw_0ZgaJpZM4Imfq4
.

----***----
John Schuster
Senior Consultant...
517 927 7400

This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.

from asciidoctor-extensions-lab.

UraniumKnight avatar UraniumKnight commented on August 20, 2024

This feature would be very welcome. My company requires us to have a list of tables and figures in our documents and I have implemented a "solution" using the extension framework and ruby magic, but it's quite ugly. It would be so nice to have this as an actual feature.

from asciidoctor-extensions-lab.

Buzzardo avatar Buzzardo commented on August 20, 2024

We are considering adding a List of Tables, a List of Figures, and (most importantly for Spring) a List of Code Examples. We want Asciidoctor to auto-generate those for us. Otherwise, the maintenance cost is too high for our team. (We don't dare rely on manually updating such things, because we have many books and many authors.)

from asciidoctor-extensions-lab.

schulle877 avatar schulle877 commented on August 20, 2024

I also implemented some ruby magic to do this:

This is my ruby function to create a toi. text is the whole adoc, which contains a META-Placeholder for inserting the list. bTable is a switch between table format and a list. logger is the global logger.

def create_table_of_images(text, bTable = true, logger)
  x = text.split(/\r?\n|\r/).grep(/Image-/).grep(/(image-counter|image-number)/).count
  logger.debug("Found " + x.to_s + " images")
  list = ""
  i=0
  x.times do
    i = i+1
    list +="|" if bTable
    list +="<<Image-"+i.to_s+">>"
    list +=" +" if !bTable
    list +="\n" if i< x
  end
  if list == ""
    list +="|{nbsp}" if bTable
  end
  text.gsub! /\|\$\{META_TABLEOFIMAGES\}[\|]{0,}/,list
  text
end

This is how my adoc-toi-placeholder looks like:

[discrete]
== Images
[stripes=none, frame=none, grid=none]
|===
|${META_TABLEOFIMAGES}
|===

As you can see, it is only a list of references.

To use the references you must define an image-id using an image-counter:

# document header
:counter: image-number: 0 # initializes the image counter
:figure-caption!: Image # turns off the automatic caption
...
image::picture.jpg[title="Image {counter:image-number}: This is a nice image", id="Image-{image-number}"]

I hope I have no typos, because I copied some snippets out of my whole script.
You can also do the same stuff with tables or whatever you like. I have a separate function for tables too.

from asciidoctor-extensions-lab.

lurch avatar lurch commented on August 20, 2024

@mojavelinux

You can do just about anything in Asciidoctor. Sometimes, it just takes some custom programming.

...which assumes that the person using Asciidoctor is also a (Ruby) programmer, which might not always be the case 😜 😆
(I do, of course, appreciate all the effort you put in to Asciidoctor ❤ī¸ )

@GeniusWaxer When I try your workaround in a book doctype PDF, it then lists "List of Figures" as Chapter 1 and "List of Tables" as Chapter 2, and my "Introduction" gets bumped up to Chapter 3 🙁
I'm a bit of an Asciidoctor newbie so is there any way I can tell it not to allocate a chapter-number for "List of Figures" and "List of Tables"? (just like it doesn't display a chapter-number next to the "Table of Contents")

from asciidoctor-extensions-lab.

lurch avatar lurch commented on August 20, 2024

To answer my own question...

is there any way I can tell it not to allocate a chapter-number for "List of Figures" and "List of Tables"?

This can be done using :sectnums!: https://asciidoctor.org/docs/user-manual/#numbering

from asciidoctor-extensions-lab.

mojavelinux avatar mojavelinux commented on August 20, 2024

This can be done using :sectnums!: asciidoctor.org/docs/user-manual/#numbering

If you're working at the API level, you can also set the numbered property on the section to false.

from asciidoctor-extensions-lab.

lurch avatar lurch commented on August 20, 2024

OffTopic:

I think this issue needs to be moved to the extensions lab.

Seems as though transferring the issue to a different repo unsubscribed me from notifications, even though I'd previously commented on this issue ☚ī¸
So for the benefit of other commenters on this issue who may want to re-subscribe to notifications...
ping @igagis @GeniusWaxer @GeekMustHave @1marc1 @znerd @UraniumKnight @Buzzardo @schulle877

OnTopic:

I don't know Ruby, and @GeniusWaxer 's solution didn't quite work for me as I have :xrefstyle: short enabled, so I've written a Python script which scans my source adoc for lines like:

.Caption for this table
[#tab-id_for_this_table]

and then writes

<<tab-id_for_this_table>> . . . . <<tab-id_for_this_table, Caption for this table>> +

into list_of_tables.adoc which I then include:: into my main adoc.
Bit of an ugly solution, but it works for now 😉

from asciidoctor-extensions-lab.

Alwinator avatar Alwinator commented on August 20, 2024

I have added a "list of figures" extension (see PR), time-wise and knowledge-wise I didn't manage to implement links, but it is the first step :)

from asciidoctor-extensions-lab.

mojavelinux avatar mojavelinux commented on August 20, 2024

I would encourage you to create a separate repository and publish the code there. This repository has gotten completely out of hand. It was meant only to be a lab to show how extensions can be used. It's not meant to be the source of extensions for this project. I don't plan to merge additional PRs into this repository for full-fledged features.

from asciidoctor-extensions-lab.

mojavelinux avatar mojavelinux commented on August 20, 2024

Fantastic! And nice work!

from asciidoctor-extensions-lab.

Alwinator avatar Alwinator commented on August 20, 2024

Thanks! :)

from asciidoctor-extensions-lab.

Alwinator avatar Alwinator commented on August 20, 2024

@Buzzardo I have added a feature to asciidoctor-lists which allows lists of code snippets! I hope you like it.

from asciidoctor-extensions-lab.

mojavelinux avatar mojavelinux commented on August 20, 2024

@Alwinator If you haven't already, I invite you to join the project chat at https://asciidoctor.zulipchat.com where you can share news about this extension to a broader audience.

from asciidoctor-extensions-lab.

Alwinator avatar Alwinator commented on August 20, 2024

@mojavelinux That would be great! I already have an account. In which stream/channel should I share my news?

from asciidoctor-extensions-lab.

bai-yi-bai avatar bai-yi-bai commented on August 20, 2024

Hello,
To fully adopt AsciiDoctor/AsciiDoctor-PDF, I need an LoF and LoT which has the same look-and-feel as the ToC. Since I am only a low-level Ruby programmer, I found and funded a developer off Fiverr.com to take the existing ToC generator in AsciiDoctor-PDF's converter.rb and modify it to produce a LoF. From the beginning, my intention was to open source this code and give it to the AsciiDoctor community to carry across the finish line. (I don't know how to package this into an extension, nor do I intend to).

I can discuss this further on the https://asciidoctor.zulipchat.com, or wherever is appropriate.
Edit Created https://asciidoctor.zulipchat.com/#narrow/stream/288690-users.2Fasciidoctor-pdf/topic/Code.3A.20List.20of.20Figures.20similar.20to.20ToC

I have posted the .rb file to my personal github here:
https://github.com/bai-yi-bai/asciidoctor-pdf-list-of-figures/blob/main/LoF/lof_extension_render_like_toc.rb

Copying from the notes I posted in the file:

This LoF has these features:

- Provides a similar look-and-feel to the existing built-in ToC (it was built upon it).
- The page number is displayed.

Known issues:

- The Figure signifier, "Figure" is not printed.
- The Figure counter, "Figure 1" is not printed.
- The ability to add whitespace between the signifier, counter, and title would be nice
- This extension only works with a specific Figure title syntax. It is unclear what syntax this is. 

Following-up on the syntax issue. I provided the developer some test files which did not print the page number, it printed "?" with this:

image::image_file.ext[title='Title']

Through testing, I found that this syntax worked:

[[Title, Title]]
image::image_file.ext[title='Title']

I'm still not sure what the correct syntax for referencing a figure is (including the figure signifier, caption/title, or page number) perhaps this is a discussion better suited to the zulipchat.

I hope that a similar approach can be used to generate a List of Tables, and List of Examples. I'm not sure if 'hooking in' to the ToC generator will work... not all documents will include an LoT, an LoF, and an LoE.

from asciidoctor-extensions-lab.

bai-yi-bai avatar bai-yi-bai commented on August 20, 2024

A solution is now available: https://gitlab.com/baiyibai/asciidoctor-pdf-lofte

from asciidoctor-extensions-lab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.