Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

My current section numbering format is something like this:

1
1.2
1.2,3

But I want it to be like this:

1-
1-2-
1-2-3-

What should I do?

share|improve this question
2  
As I said in a comment to my answer, you have redefined the wrong commands; it is not \renewcommand\section{\arabic{section}--} \renewcommand\subsection{\section\arabic{subsection}--} \renewcommand\subsubsection{\subsection\arabic{subsubsection}--} but \renewcommand\thesection{\arabic{section}--} \renewcommand\thesubsection{\section\arabic{subsection}--} \renewcommand\thesubsubsection{\subsection\arabic{subsubsection}--}. –  Gonzalo Medina Jul 4 at 15:11

1 Answer 1

up vote 10 down vote accepted

Redefine \thesection, \thesubsection and \thesubsubsection (the representation for the counters):

\documentclass{article}

\renewcommand\thesection{\arabic{section}--}
\renewcommand\thesubsection{\thesection\arabic{subsection}--}
\renewcommand\thesubsubsection{\thesubsection\arabic{subsubsection}--}

\begin{document}

\section{Test section}
\subsection{Test subsection}
\subsubsection{Test subsubsection}

\end{document}

enter image description here

Based on a comment, it seems that the bidi package is being used; in this case, the change can be made using simply \SepMark, as in the following example:

\documentclass{book}
\usepackage{bidi}

% Use either the next line or the \renewcommand lines below
\SepMark{--}

%\renewcommand\thesection{\arabic{section}--}
%\renewcommand\thesubsection{\thesection\arabic{subsection}--}

\begin{document}

\chapter{Test chapter}
\section{Test section}
\subsection{Test section}

\end{document}
share|improve this answer
    
It is my thesis file, I did this by the codes bellow; but everything went to a simple text. No bold text, etc. \renewcommand\section{\arabic{section}--} \renewcommand\subsection{\section\arabic{subsection}--} \renewcommand\subsubsection{\subsection\arabic{subsubsection}--} –  Enthusiastic Student Jul 4 at 14:53
3  
@Parsa Ah, I see the problem; notice that you are redefining the wrong commands; it is not \renewcommand\section{\arabic{section}--} but \renewcommand\thesection{\arabic{section}--} (notice the prefix "the" that you omitted in your code) and analogously fot the other commands. –  Gonzalo Medina Jul 4 at 14:58
    
I used them with 'the' and nothing happened, the output was the same. –  Enthusiastic Student Jul 4 at 15:10
    
@Parsa No, the output should not be the same. In case it is not working provide a complete little test document like the one in my answer (but complete, not just useless code snippets) showing the undesired result. –  Gonzalo Medina Jul 4 at 15:13
1  
@Parsa It seems then that you are using xelatex and the bidi package (you should have mentioned this in your question). In that case, the redefinitions I suggested must be added after loading the package, or you can use \SepMark as you mentioned in your comment. I added a remark about this to my answer. –  Gonzalo Medina Jul 5 at 1:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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