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.

This is what I want :

                    CONTAINT 

CONTAINT .............................................................. i

TABLE ...................................................................... ii

FIGURE .................................................................... iii

APPENDIX ................................................................ iv

CHAPTER I   PENDAHULUAN .................................... 1 

              1.1 Latar Belakang ................. 2
              1.2 Kontribusi ..................... 3
CHAPTER II  KAJIAN TEORI ...................................... 4

              2.1 Landasan Teori ................. 4
              2.2 Studi Pendahuluan .............. 5

I use the report class. Could anyone help me please? I'm very beginner in LaTeX and I have to write a large document with LaTeX for my bachelor graduation.

my code doesn't work well :

\renewcommand{\cftchapfont}{\large\MakeUppercase} 
\makeatletter 
\renewcommand*\l@chapter[2]{% 
    \ifnum \c@tocdepth >\m@ne 
        \addpenalty{-\@highpenalty}% 
        \vskip 1.0em 
        \@plus\p@ 
        \setlength\@tempdima{4.5em}% 
        \begingroup 
            \parindent \z@ 
            \rightskip \@pnumwidth 
            \parfillskip -\@pnumwidth 
            \leavevmode \normalfont % mengganti bfseries menjadi normal font
            \advance\leftskip\@tempdima 
            \hskip -\leftskip 
            #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par 
            \penalty\@highpenalty 
        \endgroup
    \fi
}
\makeatother 
share|improve this question
6  
The tocloft package can do this quite easily. If you search for 'tocloft' on the site you can find many examples of it in use. –  Alan Munn Aug 10 '11 at 4:24
1  
Perhaps you could explain what you mean by your code "doesn't work well". It doesn't compile? What error do you get? It compiles but doesn't look right? Where are the problems? –  Seamus Aug 10 '11 at 9:51
add comment

1 Answer

up vote 3 down vote accepted

How about this:

\documentclass{report}
\usepackage{tocloft}
\usepackage{tikz}
\usepackage[left=20mm,right=40mm,top=40mm,bottom=20mm]{geometry}

\renewcommand\contentsname{CONTENTS}

\newcommand{\newchapter}[1]%
{   \renewcommand{\thechapter}{\Roman{chapter}}%
    \chapter{#1}%
    \renewcommand{\thechapter}{\arabic{chapter}}%
}
\setlength{\cftsecindent}{2.5cm}
\renewcommand{\cftchapdotsep}{4.5}   % same spacing as for sections

\renewcommand{\cftchapfont}{\bfseries}
\renewcommand{\cftchapleader}{\bfseries\cftdotfill{\cftchapdotsep}}
\renewcommand{\cftchappagefont}{\bfseries}
\renewcommand{\cftchappresnum}{CHAPTER }
\renewcommand{\cftchapnumwidth}{2.8cm}

\begin{document}

\pagenumbering{Roman}
\addcontentsline{toc}{chapter}{TABLE OF CONTENTS}
\tableofcontents
\newpage

\addcontentsline{toc}{chapter}{LIST OF FIGURES}
\listoffigures
\newpage

\addcontentsline{toc}{chapter}{LIST OF TABLES}
\listoftables

\newpage
\addcontentsline{toc}{chapter}{APPENDIX}
\chapter*{APPENDIX}

\setcounter{chapter}{0}

\newchapter{FIRST CHAPTER}
    \setcounter{page}{1}
    \pagenumbering{arabic}

    \section{first section}
    \section{second section}

\newchapter{SECOND CHAPTER} 
    \section{third section}
    \section{fourth section}

\end{document}

enter image description here

It appears you want bigger right margins for \sections{}, but the tocloft manual states that it "should remain constant in any given document", so I'm not sure if you should change it. Probably there is another way?

The \newchapter{} just changes from arabic to roman for the chapter label itself, so the section labels are unaffected.

share|improve this answer
    
wow, that's great, thanks for this, I'll try than for both at TexMaker and Lyx –  Verly Aug 20 '11 at 5:13
    
Hii Tom, I've tried yours and as expected it running well in my Texmaker. But I have a problem when I use it in Lyx. I put the code in the preamble. No warning error. but I got my toc with no "chapter". it seem the code "\renewcommand{\cftchappresnum}{CHAPTER }" doesn't work in my Lyx. I use the same class,report. could you help me Tom? –  Verly Aug 28 '11 at 13:48
    
I don't use Lyx, but potentially I had something to do with missing %? I added them at the end of each line, please try again? –  Tom Bombadil Aug 28 '11 at 15:04
    
I'm sorry Tom, It seems I really need yor help, can I sent my code to your e-mail ? I create a class file and I combine with your code, it works well when I use it without tocloft package, but when I use that package, all of the format are unformatted. could you help me please? –  Verly Aug 30 '11 at 4:09
    
I'm not a pro, so I probably won't find the answer alone. I think it is best you post your code here (or in a new question), as there are many very skilled people on this platform. While I might find an answer after a very long time, people here usually can find a better solution than mine within a few days. –  Tom Bombadil Aug 30 '11 at 8:58
add comment

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.