I wasn't sure how to search for this as I'm not sure what's it's called. Apologies if this is a duplicate though.

Sometimes when I open a PDF, the sidebar will list the table of contents and I'll be able to jump to a section or subsection by click on it's title in the pdf viewer's sidebar. Example:

Other times, when I open up a long pdf, all I see in the sidebar are just the pages, listed in order, but with no other sort of organization. Non-example:

How do I construct my paper so that it works like the first example?

-
the `hyperref` package is the usual way of getting such things in latex, it has several commands for controlling this (bookmarks) but also by default the standard `\(sub)section` commands will add entries to the hierarchical bookmark pane. –  David Carlisle Mar 31 at 0:02
@DavidCarlisle So do I need hyperref to use \subsection? –  AlanH Mar 31 at 0:09
@AlanH no; you need `hyperref` (or `bookmark`) to create the bookmarks. –  Gonzalo Medina Mar 31 at 0:13
@GonzaloMedina Then if I use \section or \subsection, it should create a bookmark automatically, right? –  AlanH Mar 31 at 0:19
If you are using one of the two packages I mentioned, yes. –  Gonzalo Medina Mar 31 at 0:24

``````\usepackage[pdftex,pdfpagelabels,bookmarks,hyperindex,hyperfigures]{hyperref}.