@Override
   public Section getIndex(String title, int nesting, List<? extends BaseStyler> stylers) throws VectorPrintException, InstantiationException, IllegalAccessException {
      if (nesting < 1) {
         throw new VectorPrintException("chapter numbering starts with 1, wrong number: " + nesting);
      }
      if (sections.get(nesting) == null) {
         sections.put(nesting, new ArrayList<>(10));
      }
      Section current;
      if (nesting == 1) {
         List<Section> chapters = sections.get(1);
         current = new Chapter(createElement(title, Paragraph.class, stylers), chapters.size() + 1);
         chapters.add(current);
      } else {
         List<Section> parents = sections.get(nesting - 1);
         Section parent = parents.get(parents.size() - 1);
         current = parent.addSection(createParagraph(title, stylers));
         sections.get(nesting).add(current);
      }
      return styleHelper.style(current, null, stylers);
   }
@ Override public Section getIndex ( String title , int nesting , List < ? extends BaseStyler > stylers ) throws VectorPrintException , InstantiationException , IllegalAccessException { if ( nesting < 1 ) { throw new VectorPrintException ( "chapter numbering starts with 1, wrong number: " + nesting ) ; } if ( sections . get ( nesting ) == null ) { sections . put ( nesting , new ArrayList < > ( 10 ) ) ; } Section current ; if ( nesting == 1 ) { List < Section > chapters = sections . get ( 1 ) ; current = new Chapter ( createElement ( title , Paragraph . class , stylers ) , chapters . size ( ) + 1 ) ; chapters . add ( current ) ; } else { List < Section > parents = sections . get ( nesting - 1 ) ; Section parent = parents . get ( parents . size ( ) - 1 ) ; current = parent . addSection ( createParagraph ( title , stylers ) ) ; sections . get ( nesting ) . add ( current ) ; } return styleHelper . style ( current , null , stylers ) ; }
create the Section, style the title, style the section and return the styled section.

@param title
@param nesting
@param stylers
@return
@throws VectorPrintException
@throws InstantiationException
@throws IllegalAccessException