Tag Info

New answers tagged

0

The problem is that \ref{...} is not a number, but a set of instruction for printing a number. You can use the refcount package that provides \getrefnumber that expands to 0 if the reference has not yet been established or to the reference itself. I've made some other small changes (in particular protected several end-of-lines). For part/parts the syntax ...


1

The best way to cope with formatting of section titles is to use a macro with one argument in the last argument to \titleformat. Color specifications should only go in this auxiliary macro. Here is an example. \documentclass{article} \usepackage{fontspec} \usepackage{titlesec} \usepackage{xcolor} \usepackage{lipsum} % Title/Heading Formatting % SECTION ...


2

Just as with your specification for \section, you can move all the printing commands into the final argument. This then allows you to color them with \textcolor. In your example you then get on page two, rather a page break between the section commands. \documentclass{article} \usepackage{fontspec} \usepackage[explicit]{titlesec} \usepackage{xcolor} ...


5

One option using titlesec and fmtcount (to easily get the ordinal string for the chapter counter); using fancyhdr and a simple redefinition for \chaptermark gives the desired formatting for the header: \documentclass{book} \usepackage[a6paper]{geometry}% just for the example \usepackage{titlesec} \usepackage{fmtcount} \usepackage{fancyhdr} ...


3

The argument of section is used in more than one place. It can wander in the header and the toc. Some commands ("fragile commands", see http://www.tex.ac.uk/cgi-bin/texfaq2html?label=protect) can break in this case. Either use \protect\onetimegloss{foo} or \section[text for toc and header]{\onetimegloss{foo}} or define a robust command with ...


0

Here is an idea \documentclass{beamer} \newwrite\mtwrite \immediate\openout\mtwrite=app\jobname \newif\ifsec \newif\ifsubsec % this is not the best way to redefine (sub)section \command \let\mtsection\section \renewcommand{\section}[1]{% \mtsection{#1}% \def\mtsec{#1}% \sectrue\subsecfalse} \let\mtsubsection\subsection \renewcommand{\subsection}[1]{% ...


1

Basically any documentclass I've used so far has sectioning commands such as \section, \subsection etc. which provide an optional argument which is meant for the title designed for the ToC, whereas the mandatory is used in the document text as heading. This was introduced to limit the length of ToC entries, but it can be used to abbreviate headings for the ...


1

Here is a first attempt that seems to provide section cloning and moving to the appendix (although I changed the macro names to be a little more self-documenting). But I'm very unfamiliar with TeX macro hacking, and I'd like some suggestions to make it more idiomatic, safe, and functionality-complete. Update: this seems to create all sorts of rendering ...


1

You can use a redefinition of the internal \beamer@@ssection* (original definition in beamerbasesection.sty) so \section* removes the titles from both the table of contents and the navigation elements in the headline: \documentclass{beamer} \usetheme{Singapore} \makeatletter \long\def\beamer@@ssection*#1{\beamer@section[]{}} \makeatother ...


5

Peter's answer has the disadvantage of printing the text you put before subsection numbers in references to the subsections and in the ToC, as well. To avoid that, instead of renewing the meaning of \thesubsection, it's better to load the titlesec package and define \titleformat{\subsection}{\normalfont\large\bfseries}{Task \thesubsection}{1em}{} MWE: ...


2

Update: You can use \newkomafont to set a default font style for the numbers for all section levels and for the single section levels. Later these defaults can be changed using \setkomafont and \addtokomafont. Of course the \...format commands must be redefined in a way that they use the related \usekomafont{...} commands. Then it is easy to change the ...


7

The command \othersectionlevelsformat, in latest versions of KOMA-Script, doesn't work as before any more (to say the truth I think it's there for backwards compatibility only). Now every sectioning command has its own formatting command. Here's a list: \partformat \chapterformat \sectionformat \subsectionformat \subsubsectionformat \paragraphformat ...


4

I would say that really much depends on what you are trying to achieve. Do you want to make a class that others can use as well? You can define your own commands for sectioning. Are there just minor changes within one of your documents? Use package etoolbox and patch your changes. Are there bigger changes to the sectioning and titles? Package titlesec is ...


5

The titlesec or sectsty packages are your friends for the standard classes. If you want some more control, try the komascript classes or memoir. See the UKTeXFAQ.


6

There's no problem if you correctly use \MakeUppercase instead of \uppercase. Note also the placement. \documentclass{article} \usepackage{titlesec} \titleformat{\section} {} {\thesection.\enskip} {0pt} {\MakeUppercase} \begin{document} \begin{equation} x\label{eq:x} \end{equation} \section{A reference to \ref{eq:x}} \end{document} When ...


2

A solution with enumitem package, here without changing the paragraph counter format, only the enumi label is prepended with \arabic{paragraph} in the \setlist command. This will be applied for all enumerate environments. If the change should be local only, just say \begin{enumerate}[label={\arabic{paragraph}.\arabic*}] then. \documentclass{article} ...


1

I placed the redefinition of \contentsline after \begin{document} since hyperref puts what appears to be a redefinition in the aux file. But on closer examination it seems this code doesn't actually do anything. \documentclass{scrreprt} \usepackage{hyperref} \makeatletter \let\hyperchapter\chapter \def\chapter{\@ifstar\starchapter\mychapter} ...


5

\section is not defined in the latex kernel it is defined (or not) in each class file. The implementation in article for example is just one definition \newcommand\section{\@startsection {section}{1}{\z@}% {-3.5ex \@plus -1ex \@minus -.2ex}% {2.3ex \@plus.2ex}% ...


1

Here's a very simple solution: create your own command that puts the page number into the section heading. \newcommand{\mysection}[2]{% \section*{#1 (p.~#2)}% } Use it like this: \mysection{35}{Macros}


3

Do you just want something like this? I'm still not entirely clear what the command should do about the page but maybe you don't want it to do anything? \documentclass{article} \usepackage{titlesec} \titleformat{\section}[runin]{\Large\bfseries}{\thesection}{0pt}{}[] \setcounter{secnumdepth}{0} \begin{document} \section{Name of the section} (page) ...


1

Special care must be taken, of course, in order to produce the correct output also in the table of contents. The \@part command, as defined in the amsbook document class, issues an \addcontentsline command as follows: \addcontentsline{toc}{part}{\partname\ \thepart. \protect\enspace\protect\noindent#1}% As you can see, a period is added after \thepart; ...


4

The fifth argument to \@startsection should be positive: \documentclass[oneside]{amsbook} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lipsum} \makeatletter \renewcommand\section{% \@startsection{section}{1} \z@ {.3\linespacing\@plus\linespacing} {1sp} {\normalfont\bfseries\centering}% } \makeatother \begin{document} ...


4

You need to redefine \@makechapterhead (for numbered chapters) and \@makeschapterhead (for unnumbered chapters) and \section (the original definitions can be found in report.cls): \documentclass{report} \usepackage{lipsum}% just for the example \makeatletter \def\@makechapterhead#1{% \vspace*{50\p@}% {\parindent \z@ \raggedright \normalfont \ifnum ...


2

\glsaddall is adding the vertical space. If you use this command on a different page, the section headings come out correctly: \documentclass[12pt,a4paper]{article} \usepackage[left=3.0cm,top=2.0cm,right=2.0cm,bottom=2.0cm]{geometry} \usepackage[ nonumberlist, nopostdot, nogroupskip, acronym, toc, nomain, section] {glossaries} \makeglossaries ...


2

You need to use the (representation for) counter for subsections and you had the one for sections. You need \thesubsection instead of \thesection in \titleformat{\subsection} {\normalfont\Large\bfseries}{\thesection}{1em}{}[{\titlerule[0.8pt]}] You can introduce the color specification in the second mandatory argument (affects number and title) or in the ...


1

Yes, there is. Instead of simply writing \subsection{} add a space as the argument of the \subsection: \subsection{ } From a TeX point of view it changes nothing in your document, but WinEdt is now able to collect that \subsection in its Tree interface, since the argument is now non-empty. With this minimal example \documentclass{article} ...


1

There is no direct command for the page distance but it's possible to use the refcount package by Heiko Oberdiek (One of the TeX Gurus here on TeX.SX ;-)). The problem with references is that they could be anything (numbers, links etc.) and the commands \ref and \pageref are not expandable. However, the \getpagerefnumber{label} command returns a pure number ...


0

The question is not clear but here an aswer Here you can do bookmark anywhere in your document, just right clic the bleu arrow. If you realy need a subsection without any heading (caption) that's mean something just like \subsection{} you can do \subsection{\empty}


1

You can copy the pagestyle headings and then change the marks of the new page style: \copypagestyle{partheadings}{headings} \makepsmarks{partheadings}{% \createmark{part}{both}{nonumber}{}{}% \clearmark{chapter}% \clearmark{section}% } Now you can use \cleardoublepage \pagestyle{partheadings} to set the page style inside the document. Code: ...


1

One simple way to suppress numbering globally is issuing: \setcounter{secnumdepth}{0} In that case you can just use the unstarred versions, they would be unnumbered but appear in the toc. For more advanced configurations I would advise you to use the titlesec package.


1

I think this is wanted if report is used, the sectioning level hierarchy is (starting from top) \part \chapter \section \subsection \subsubsection \paragraph \subparagraph In my point of view \paragraph and \subparagraph should not be used, since that levelling is too deep. \documentclass[12 pt]{report} \usepackage[left= 12 mm,top=1 in,bottom=2 in ...


2

You start with \section and it is counted as chapter.section. But you have no chapter defined, so it uses 0.1. Use the article class instead or define a \chapter{...} before using \section{...}


1

Modeling \partmark on \chaptermark and redefining the latter: \documentclass[a4paper,french,12pt,oneside,openright]{memoir} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage[french]{babel} %langue francaise \usepackage{titlesec} \usepackage{lipsum} %paragraphes prédéfinis \usepackage{verbatim} \usepackage{booktabs} ...


4

This is how the class defines the fonts for the various parts of the document: \newfont{\secfnt}{ptmb8t at 12pt} \newfont{\secit}{ptmbi8t at 12pt} %13 Jan 00 gkmt \newfont{\subsecfnt}{ptmri8t at 11pt} \newfont{\subsecit}{ptmbi8t at 11pt} % \newfont{\ttlfnt}{phvb8t at 18pt} \newfont{\ttlit}{phvbo8t at 18pt} % GM 2/4/2000 \newfont{\subttlfnt}{phvr8t ...


1

One option might be to add the following to your preamble: \makeatletter \definecolor{myyellow}{rgb}{0.99,0.78,0.07} \def\@makechapterhead#1{% {\parindent\z@ \raggedright \hangindent12\p@ \advance\hangindent1em \refstepcounter{chapter}% %\textcolor[rgb]{0.99,0.78,0.07}{\rule{12\p@}{12\p@}}\quad ...


1

It depends on your actual intent. If, as was mentioned in comments to the question, the desired change is to obtain a different vertical alignment for unnumbered chapters produced using \chapter* (such as the ToC, LoF, LoT), you can use \printchapternonum. A little complete example in which I changed the original ...


1

Here's one possibility using the standard book (or report) class and fancyhdr; the etoolbox package was used to patch \@part so as to grab the part title: \documentclass{book} \usepackage[a6paper]{geometry}%just for the example \usepackage{fancyhdr} \usepackage{etoolbox} \usepackage{lipsum}%just for the example \makeatletter \patchcmd{\@part} ...


1

Using scrlayer-scrpage from the KOMA-bunndle and a bit of hackery. \documentclass{book} \usepackage{blindtext} \usepackage{scrlayer-scrpage} \automark[chapter]{part} \usepackage{etoolbox} \makeatletter \apptocmd{\@part}{\partmark{#1}}{}{}% thanks to esdd and Markus \makeatother \begin{document} \part{dance} \chapter{walzing wombat} \blindtext[10] ...


1

Try this with an additional optional argument for the \section macro, holding the \sectionmark. \documentclass[a4paper]{book} \usepackage{blindtext} \usepackage{fancyhdr} \usepackage{xpatch}% \usepackage{xparse} \usepackage{hyperref} \let\LaTeXStandardSection\section \newif\ifinternalsectionmark \internalsectionmarkfalse \xpatchcmd{\@sect}{% ...


0

EDIT: caveat emptor: this answer seems to be wrong - i.e. the only reason it works, is because the tableofcontents is dumped right before that section; if you move that part earlier, then it will not work.. Eh, apparently we can use the old \let\oldcmd\cmd ... \let\cmd\oldcmd hack, but here with counters (so if anyone has a better solution, I'd love to ...


6

\circled is a fragile command this way (due to the \tikz etc content). It must be \protected then. Or define it with \DeclareRobustCommand, as for example \robustcircled, which can be used without \protect then. As a general rule: Use robust commands as arguments to the \section etc. commands. \documentclass[11pt,a4paper]{article} \usepackage{tikz} ...


1

What you want to do can be done simply using \insertsectionhead and \insertsubsectionhead: \newcommand\settitle{ \frametitle{\insertsectionhead} \framesubtitle{\insertsubsectionhead} } An additional advantage now is that a frame appears before a \subsection command has been used, no subtitle is produced (See example below). A complete example: ...


0

Edit: After exchange some though I decided to rewrote my answer: One way to obtain what you wish is use hyperref packages and its namref option. With it I define new variant f section which include autogenerated labels. They are used in definition of \settitle: \documentclass{beamer} \usepackage{hyperref} \let\oldsection\section ...


1

The \label must be written after \caption, not before. Labels need a \refstepcounter (here with figure counter) such that the latest stepped counter is known and the reference is correctly written. If \label{Figure: SimplyStupid} is used before \caption, it will use the last counter being stepped, this is section, that's why the reference prints II (the ...


3

Here is a solution with titlesec. The idea is to put the subsection label and title in the margin with the llapcommand, and smashing it, so as the lines in the body remain at the same level on the page. Section title hanging w.r.t. the label is obtained with a tabularx environment, of prescribed width 3in - 0.75 in. Finally I had to compensate the interword ...


3

Here's something that (probably) does what you want. It doesn't use Arial, because I don't have it and don't like it, but substitutes Latin Modern Sans. You type \newsection with two arguments; the first says which type of \newsection it is, and the second is the section name. a is one type (no number, blue), b is another (no number, still black, no font ...


2

The code below gives us the following output: % arara: xelatex \documentclass{scrreprt} \usepackage{blindtext} \usepackage{fontspec} \usepackage{xcolor} \DeclareSectionCommand[beforeskip=-10pt,afterskip=10pt, font={\color{blue!40!black}\fontspec{Arial}\normalfont}, style=section, level=1, tocindent=2em, tocnumwidth=2em, indent=0pt ...


2

This can be achieved for example with a small patch to the \@sect command, which is responsible for the typesetting of the section title. The specific section type must be filtered and then \xrfill with a raising of about half of the letter height (0.5ex), a rule width and a rule colour (see the package documentation) (For this question I used some code ...


1

A call to \section steps the section counter before setting the actual title. So, using something like \setcounter{section}{5} \section{A section}% 6 will print the section as 6 A section, rather than perhaps a more intuitive 5 A section. The same goes for a subsection. So, if you want a specific sectional unit to have a number X, you can set it before ...


2

You can patch the standard report document class to achieve this as follows. \documentclass{report} \usepackage{etoolbox} \makeatletter \patchcmd{\@part}{\huge\bfseries \partname\nobreakspace\thepart} {\huge\bfseries \thepart\nobreakspace\partname}{}{} \makeatother \begin{document} \part{The first} \part{The second} \end{document}



Top 50 recent answers are included