views:

258

answers:

5

I have an FAQ in HTML (example) in which the questions refer to each other a lot. That means whenever we insert/delete/rearrange the questions, the numbering changes. LaTeX solves this very elegantly with \label and \ref -- you give items simple tags and LaTeX worries about converting to numbers in the final document.

How do people deal with that in HTML?

ADDED: Note that this is no problem if you don't have to actually refer to items by number, in which case you can set a tag with

<a name="foo">

and then link to it with

<a href="#foo">some non-numerical way to refer to foo</a>.

But I'm assuming "foo" has some auto-generated number, say from an <ol> list, and I want to use that number to refer to and link to it.

+1  A: 

Instead of \label{key} use <a name="key" />. Then link using <a href="#key">Link</a>.

Filip Navara
But this doesn't generate the actual numbers, does it?
dreeves
+6  A: 
Jörg W Mittag
Got any pointers to the solutions you mention? I ended up hacking up something in PHP which I can post here as an answer if anyone's interested.
dreeves
(I posted my solution.)
dreeves
+2  A: 

I know it's not widely supported by browsers, but you can do this using CSS counter. Also, consider using ids instead of names for your anchors.

p4bl0
+1  A: 

PrinceXML can do that, but that's about it. I suppose it'd be best to use server-side scripting.

Ms2ger
A: 

Here's how I ended up solving this with a php script:

http://yootles.com/genfaq

It's roughly as convenient as \label and \ref in LaTeX and even auto-generates the index of questions. And I put it on an etherpad instance which is handy when multiple people are contributing questions to the FAQ.

dreeves