2

I have a latex file that i wish to convert into an html document. It is made up of many sub-files with a master document. I want to hyperlink different parts/sections of these files(included/master-file) among themselves just like a wiki.

1 Answers1

3

You can put chapters or sections to standalone pages using a command line option. The hyperlinks can be added using the \nameref command provided by the Hyperref package. It is based on the standard label/ref mechanism.

You didn't provide any example, so here is my MWE, sample.tex:

\documentclass{book}
\usepackage{lipsum}
\usepackage{hyperref}
\title{Site title}
\author{Neutrino}
\begin{document}
\maketitle

\input{hello-world}
\input{another-section}

\end{document}

It includes two files, hello-world.tex:

\chapter{Hello world}
\label{chap:hello-world}
\lipsum

The second file is named another-section.tex:

\chapter{Another section}
\label{chap:another-section}

We can try to link to chapter~\nameref{chap:hello-world}.

\lipsum

You can see the \nameref command use here.

Compile the document using the following command:

make4ht sample.tex "2,sec-filename"

The options after the filename require cutting of chapters to standalone HTML files. The names of the generated files will be based on the chapter titles. This feature is enabled using the sec-filename option.

The sample.html will contain title and table of contents:

enter image description here

The file Anothersection.html contains link to the Hello world chapter:

enter image description here

michal.h21
  • 50,697