add tag
4 years ago JeT

My question

The same way it’s often (always?) a good idea to turn a table into a graph, I’d like to be able to simply turn (long) lists into mindmaps by wrapping these lists into a mymindmap environment.

Example

image.png

vs same content in this long nested list (I could have splitted into 3 frames, but for the sake of the example, I left it as a long list).

image.png

image.png

Context and previous building blocks

Long itemize and enumerate are boring, especially on beamer.

Mindmaps are great, but I find them difficult to include cause of the nested {} that take some time to debug.

  1. Thanks to this (canonical IMO) answer, the organization of mindmaps is automatically handled and leads to regular growing cycle, easy to parameter with pgfkeys.

  2. Thanks to this answer, it’s easy to create your own style for the mindmap.

What could this environment look like ?

To turn lists into mindmaps, I’d like to create a simple environment that could (open to any alternative) look like this

MWE

Top Answer
4 years ago user 3.14159

This is not an answer to the question in the strict sense, but a suggestion to try an alternative approach. Rather than trying to convert a bunch of itemize environments and \items into a mindmap one can convert the contents of a mindmap to other formats, such as itemized lists. IMHO the TikZ approach is cleaner in that it specifies the relations and hierarchies, and allows the user to control the details via keys. Although I did not try this out explicitly, I’d think that one could then convert the same input to other formats such as forest trees.

Since the codes shown here are already extensive, I just show a basic example. The parser is shamelessly stolen from the calc library of TikZ, one could also use the parser of the \path command if one wants to make it a bit richer.

Screen Shot 2021-06-07 at 1.02.52 PM.png

As you can see, you only have to sandwich the contents of the mindmap in

to get the list. Notice that in the end I added “non-expandable” commands to show that this is at least somewhat robust.

In general I’d think that allowing for such arguably more “semantic” input may make a lot of sense when dealing with documents that may eventually become parts of, say, beamer presentations.

4 years
JeT — Monday, 7th Jun 2021 21:24

@marmot, re: your answer, I like your alternative since that’s exactly where I want to go 😃 I noticed the child {node {level \pgfmathparse{3}\pgfmathresult}} test for robustness.

18 hours
user 3.14159 replying to JeT — Monday, 7th Jun 2021 03:24

You can do this with \newenvironment. I am not sure what would be the best way to solve your problem. In many ways the TikZy way is, in my humble opinion, the “better” way.

What I want to say is that David’s answer is great, and really cool. However, if you wanted to replace

by, say,

you would run into trouble. (I know that you could use xfp in that case but this is just to illustrate that this is slightly less robust than one may possibly want it to be.) If you would this have the content of a node in the mind map, there would be no problem, In other words, if one had a parser that takes all the child and node commands and turn them in an itemized list, or a mind map, depending on what you want. However, if one was to play this out in full glory, this would require that one would go in more or less the opposite direction of the LaTeX3 route, and develop such conditional parser. Probably this will not be something that ever materializes, at least in LaTeX.

5 hours
JeT replying to user 3.14159 — Sunday, 6th Jun 2021 22:34

I spent the whole afternoon trying to build that new environment, but I think I’m facing my lack of knowledge of TeX primitives . I fail to integrate the \def\begin#1 or \def\end#1 into an environment. What would you advise me to read to go forward ?

11 hours
JeT — Sunday, 6th Jun 2021 11:33

Nice answer from D Carlisle on the nested list switch to tree syntax. Now I need to wrap all this into an environment so that I could type :

After that, mindmaps will just be so simple to type I’ll need to refrain myself from over-using it 😃

a day
JeT replying to user 3.14159 — Saturday, 5th Jun 2021 00:17

I rephrased the question where you seemed to have an idea for this very case (beamer).
In parallel, I launched the general question (not mentioning beamer there).

user 3.14159 replying to JeT — Saturday, 5th Jun 2021 00:16

I think that similar questions have been asked before, after all we were finding some related posts. I’d recommend to ask for beamer compatibility as an option, but support for nested environments as a requirement.

14 minutes
JeT replying to user 3.14159 — Saturday, 5th Jun 2021 00:02

Cause you’re the brain behind the original question 😃

user 3.14159 replying to JeT — Saturday, 5th Jun 2021 00:00

Why would I?

JeT replying to user 3.14159 — Friday, 4th Jun 2021 23:57

Uff… I forgot about this case too !
Do you mind if I ask the question"How to robustly capture the contents of nested lists ?" on TeX.SE ?

23 minutes
user 3.14159 replying to JeT — Friday, 4th Jun 2021 23:34

Yes, this is also an interesting post. But remember that in beamer \item can be also followed by <2->, say. The problem with all these hacks is that they are not universal to the best of my knowledge.

31 minutes
JeT replying to user 3.14159 — Friday, 4th Jun 2021 23:03

Going in your direction here

11 minutes
JeT replying to user 3.14159 — Friday, 4th Jun 2021 22:52

Thank you Socrates! Am telling you… In LaTeX… the \chi is not an X… it’s 2 braces }{!! They 're its common source of solution and problems 😃

user 3.14159 replying to JeT — Friday, 4th Jun 2021 22:47

Certainly if you use \item{...} instead of \item ... this is a much easier problem.

JeT replying to user 3.14159 — Friday, 4th Jun 2021 22:40

You’re absolutely right, questions can be be nested in exam ! I was kinda confirming your point that in that case too, nesting was not possible in the provided answer.
I am probably missing a conceptual thing but \item looks like a command with no argument (actually, \item[ ] makes me think it is the case). Am I wrong then if I says that if \item was written \item{with the content into braces} we could find a way to save this argument ?
Just checked th TexBook
blob

14 minutes
user 3.14159 replying to JeT — Friday, 4th Jun 2021 22:26

I am not too familiar with exam but can you nest the question environment there? Anyway, I am not saying that it is impossible but to my knowledge there is no robust and uncontrived way of capturing the contents of nested lists with \items on the market. Of course, I may well be missing some information.

JeT replying to user 3.14159 — Friday, 4th Jun 2021 22:21

Merci to reframe the problemS 😃
I feel a bit like Nemo since I asked some time ago a question about exam and choiceis just another type of item…
The answer then was to use TeXSoup (not easy btw). It worked for non nested list again.
Let me rephrase and restructure my question to cope with your second point.

an hour
user 3.14159 — Friday, 4th Jun 2021 20:56

@JeT, re: your question, I think that this question contains two questions. One of them is to capture the contents of itemize environments. This is actually surprisingly messy. For instance, here is a method that can be used in principle, but as far as I can see it does not really support nested itemize (or enumerate) lists. So, if you insist on itemize or similar lists being converted to mind maps, you may want to start out with a more general question of how to robustly capture the contents of nested lists. (It is possible, though, that in this very case one could get away with a simple cheat.)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.