4

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?

enthu
  • 3,795
  • 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 04 '14 at 15:11

1 Answers1

11

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}
Gonzalo Medina
  • 505,128
  • 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}--} – enthu Jul 04 '14 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 04 '14 at 14:58
  • I used them with 'the' and nothing happened, the output was the same. – enthu Jul 04 '14 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 04 '14 at 15:13
  • My TeX code is a little complicated and I am very very basic to work with it. But a friend of mine told me this and workd for the text not in the margins: put \SepMark{-} before ‎\begin{document}‎‎ – enthu Jul 04 '14 at 19:10
  • 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 05 '14 at 01:21
  • Yes you are right. Thanks by the way. You made a huge help to me. – enthu Jul 05 '14 at 05:35
  • Just say, \SepMark{-} works, not \SepMark{--} – enthu Jul 05 '14 at 05:54