If you want numbered headings to be underlined, but do not want a line under the number, it can be difficult if you don't know how it works. This is because by default, the format of the number follows the format of the text that follows it. For example, let's say you want to underline a paragraph in a Heading 2 style. Chances are it will look like this:
Defined lists are often used to track paragraphs for numbering purposes. When you create a paragraph style for numbering, you can assign the style to a defined list, and paragraphs are numbered in that style according to where they appear in the defined list. The first paragraph to appear is given number 1 (“Table 1”), for example, and the next paragraph is given number 2 (“Table 2”), even if it appears several pages later. Because both paragraphs belong to the same defined list, they can be numbered consecutively no matter how far apart they are in the document or book.
One of the harder things to do in Adobe InDesign, surprisingly for a page layout tool, is to create multilevel or outline format numbered lists. The right way to accomplish this, according to the folks at Adobe, is to create a Style for every level of the list you’d like to have! Here are Adobe’s instructions on how to do so (This content is taken directly from https://helpx.adobe.com/indesign/using/bullets-numbering.html#create_multi_level_lists):
After years in the graphic design and art industry, there’s one thing that I can’t understand: why designers try to get along without Adobe InDesign. I’ve been using this program for many years, and it’s helped me work efficiently and productively. I’ve created this website to show everyone that InDesign is a program that you can and should learn, and the best program for layout and desktop publishing. If you’re interested, check out my book on creating an ePub with InDesign. It’s got all you need to know in order to take your eBook from the final draft to an interesting and well-formatted ePub book.
See Word's Numbering Explained by John McGhie, MVP - comprehensive and not pretty (Downloadable pdf file in letter size) - Reading this is vital to anyone attempting to use automatic numbering or bullets in a law office setting or other places where the documents are likely to be reused or heavily edited. See also How to Create a Template with a downloadable template with style-based numbering.