Let's go,

Here is the result my .tex file gives me now :

enter image description here

Here is the result I want :
(see the "2" position on the right side,
image obtained by replacing
\cellcolor{blue!25} \colorbox{green}{\parbox[b][0.2cm][b]{0.377cm}{\subsection{}}} with \textbf{2}.)

enter image description here

Here is the MWE XeLaTeX code :

\usepackage[table]{xcolor} % To have a colored background.
% To keep "2" (the bold one) and "3" at the same size.
% To delete the section number of the numbering subsection.

% Used for gopsel chapters (to count a new subsection).
                  foo bar baz & 6 &                                          \\
                  foo bar baz & 3 & \cellcolor{blue!25} 
                      \colorbox{green} {\parbox[b][0.2cm][b]{0.377cm} {
                        }}                                                   \\ 
                  foo bar baz & 9 &                                          \\
                  foo bar baz & 14 &                                         \\
                  foo bar baz & 2 &  \textbf{3}                              \\
                  foo bar baz & 8 &                                          \\

Here is the context (why I want that) :

I want to have the four gospels in a LaTeX format.
The gospels are 4 books, and for each one, there are several chapters that includes multiple verses.

So, before starting directly with the first gospel,
I want to have a table of content where the 4 books and their chapters are listed
(because I want to be able to access them just by clicking on their link in a table of content).

Books (which are gospels) would be considered as \part,
their chapters as \section,
and if I need it later, their verses as \subsection
(for the MWE the question here is about the verses numbers, the \subsection).

So here you can have a preview of what a gospel's page looks like :

enter image description here

(At the top,
we have the title of the book : which gospel is it (here it's from the Matthew one).

At the very left side,
we have a big bold "1" which correspond to the chapter number of the passage.)

At the very right side,
we have little bold numbers which correspond to verses number.

And at the sides next to the vertical lines,
we have the greek words-lines-sided numbers according to their place in their verse.

• So, to organize all of that, I use a \tabular of six columns (here we have 3 because of the MWE).

Why I put a \parbox between \tabular cell and \section ?
Because, it seems that I can't register the chapter number into the table of content without \parbox.

I'm rather like novice in LaTeX, so it's possible that I made it in bad or not ingenious way.
Also, I'm not an english native speaker, so there're maybe mistakes in the text.

Thanks a lot for any help.

  • Could you please make your example code compilable? (see minimal working example (MWE))
    – leandriis
    Sep 15, 2019 at 13:36
  • MWE added, thanks.
    – gustav.b
    Sep 15, 2019 at 15:36
  • Thanks for adding the MWE. Could you please also explain why you disable numbering of subsections and later on use a subsection with manually entered numbers inside of a tabular?
    – leandriis
    Sep 15, 2019 at 15:47
  • Some more context would help here, since a redefinition of \subsection to just set the counter number in bold (and write something to the ToC) would suffice as a solution. But I guess that's not what you're after.
    – Werner
    Sep 15, 2019 at 16:16
  • 1
    @leandriis Explanation given.
    – gustav.b
    Sep 15, 2019 at 18:07

1 Answer 1


Probably something like the following is closer to what you want to achieve:

enter image description here







\part{title of the gospel}

      \mygospelchapter   &1& foo bar baz & 6 &                                         \\
                         &2& foo bar baz & 3 & \myverse                                \\
                         &3& foo bar baz & 9 &                                         \\
                         &4& foo bar baz & 14 &                                        \\
                         &5& foo bar baz & 2 & \myverse                                \\
                         &6& foo bar baz & 8 &                                         \\
                         &7& foo bar baz & 2 & \myverse                                \\
                         &8& foo bar baz & 8 &                                         \\


\newcounter{gospelchapter} is used to define a new counter with the name gospelchapter. \setcounter{gospelchapter}{1} is used to set this newly defined counter to a value of 1.

\newcommand{\mygospelchapter}{\addcontentsline{toc}{section}{\thegospelchapter}\Large\bfseries\thegospelchapter\refstepcounter{gospelchapter}} is a newly defined command that can be used inside of your table (left column) to insert a bold number and to create a corresponding entry in the table of contents. The command makes use of the following:

\addcontentsline{toc}{section}{\thegospelchapter} adds an entry to the table of sontents (toc). The added entry is at the level section and the text that is added to the table of contents is \thegospelchapter. \thegospelchapter itself prints the current value of the gospelchapter counter. \Large\bfseries\thegospelchapter prints the current value of the gospelchapter counter at the place where the \mygospelchapter command was used and makes sure that the number is printed in large and bold. \refstepcounter{gospelchapter} finally makes sure to increase the gospelchapter counter by one.

An analogous set of commands is also used for the new counter verse and the corresponding command \myverse that can be used inside of the table. Verse entries are added to the table of contents at the subsection level.

  • Thanks a lot, just I don't understand {\theverse}\bfseries\theverse\refstepcounter{verse}} especially what is \theverse and verse, same with regard to the chapters, I can not compile your code.
    – gustav.b
    Sep 16, 2019 at 11:14
  • @gustav.b: I have edited my answer to add some explanation on the \mygospelchapter and \myverse commands and the corresponding counters that I newly defined. I hope this helps. If there are any questions left, please feel free to ask.
    – leandriis
    Sep 16, 2019 at 11:45
  • @gustav.b: You wrote: " I can not compile your code." Did you try with the exact same example from my answer or did you try to incorporate code from my answer into your question? Do you recieve any error messages?
    – leandriis
    Sep 16, 2019 at 11:46
  • Thanks to have explained what I misunderstood (but how \thegospelchapter knows he has to print the current value of the gospelchapter counter and not another for example? How the link between \thegospelchapter and the gospelchapter counter is made ?).
    – gustav.b
    Sep 16, 2019 at 12:34
  • About the compilation, yes I copy your code, create a new folder as well as a new tex file inside, paste your code into, and compile it as XeLaTeX code. So I didn't try to incorporate code from you answer into mine own code. I try to compile it 3 times. Here is the error displayed : Package hyperref Warning: old toc file detected, not used; run LaTeX again. (/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/se-ascii-print.def) Package hyperref Warning: The anchor of a bookmark and its parent's must not (hyperref) be the same. Added a new anchor on input line 21. )
    – gustav.b
    Sep 16, 2019 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.