New answers tagged

1

You can redefine \sectionmark to suit your needs. Additionally, I've added what's needed for the Page ##/total (see How can I add "page # of ##" on my document?). \documentclass{article} \usepackage{fancyhdr,lastpage,lipsum} \pagestyle{fancy} \fancyhf{} \fancyhead[L]{Section~\leftmark} \fancyhead[R]{Page \thepage/\pageref{LastPage}} \...


1

If you want that the header contains just “Section 1” (or whatever the section number is), redefine \sectionmark: \renewcommand{\sectionmark}[1]{\markright{\thesection}} (the word “Section” is already supplied by the other code). This way, \rightmark will contain the current section number.


3

The line \renewcommand{\sectionmark}[1]{\markright{\arabic{section}.\ #1}} sets the section mark to consist of - the section number as a Arabic numeral - followed by a fullstop and space - followed by the section name Just us \renewcommand{\sectionmark}[1]{\markright{#1}} instead to remove the number and accompanying punctuation. \...


0

This worked for me: \chapter*{Introduction}\stepcounter{chapter}\addcontentsline{toc}{chapter}{Introduction} Place that code at the beginning of your chapter.


1

Here's the centered \section* version with code from latex.ltx (as is used in standard classes) \documentclass{article} \makeatletter \def\@sect#1#2#3#4#5#6[#7]#8{% \refstepcounter{#1}\edef\@svsec{\csname the#1\endcsname.\hskip 0.6em} \begingroup \ifnum #2=1\bf\centering {\interlinepenalty \@M \large{\@svsec #8}\par}\else\...


7

This was caused by \value{0}, which is not valid. Simply 0 is enough. use \value only when accessing counters, as you do with \value{chapter}. Also, you don't need to use \makeatletter/ \makeatotherhere. See What do \makeatletter and \makeatother do?, though I suspect you already know this. Output Code \documentclass{memoir} \usepackage[utf8]{inputenc}...


16

Define an environment within which counter stepping and ToC-writing is disabled. This allows great freedom: \documentclass{article} \usepackage{xparse} \newcounter{savesection} \newcounter{savesubsection} \newcounter{savesubsubsection} \newenvironment{quietsections} {% Store sectional counters \setcounter{savesection}{\value{section}}% \...


11

UPDATE at the end, with automatic restoration of arbitrary counters!!!! Use a dummycounter that resets with the upper section level and \let\c@subsection\c@dummycounter, i.e. explicitly use the count register c@dummycounter instead of c@subsection If this is used inside of the minipage, the \let operation does not leak outside (since minipage is an ...


1

A big issue you have to deal with is expandability of content, since you're writing to the terminal. To get around this, I define two versions of your \myapp and \myproduct functions. The regular \myapp and \myproduct are declared to be robust, while \@myapp and \@myproduct are expandable and simplified versions of their counterparts (removing font-related ...


2

The bug is fixed in KOMA-Script Version 3.21 which is the current version on CTAN, in TeX Live 2016 and in MiKTeX. \documentclass{scrartcl}[2016/06/14] \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{xcolor} \usepackage{scrlayer-scrpage} \addtokomafont{section}{\color{red}} \addtokomafont{pageheadfoot}{\color{blue}} \begin{document} ... \\...


2

With a KOMA-Script class you can use \addsec. Then it is possible to define a short title in the optional argument. \documentclass{scrreprt} \usepackage{hyperref} \usepackage{cleveref} \begin{document} \tableofcontents \chapter{chapter} \section[short title 1]{Long Title Section One}\label{sec:One} In \cref{sec:One} (\nameref{sec:One}) I refer to \nameref{...


3

Perhaps KOMA classes provide better ways, but \@currentlabelname has to be set (alternativle \NR@gettitle) to be effective with nameref, i.e. use the optional argument value #2 as content of \@currentlabelname! \documentclass{scrreprt} \usepackage{hyperref} \usepackage{cleveref} \usepackage{xparse} \makeatletter \let\latex@@section\section \...


1

Is this what you want? \documentclass{article} \usepackage{fontspec}% use xelatex \usepackage{titlesec}% adds \thetitle and \@currentlabelname \usepackage{nameref} \usepackage{regexpatch} \usepackage{currfile}% adds \currfilepath % Define a couple commands to track \newcommand\myapp[1]{\textit{#1}} \newcommand\myproduct[1]{MacGyver.\textit{#1}}% ...


2

Here is a solution Notes The solution use (la)TeX loop. File names changed 1_1_1 -->1+1+1 (this is easier) \documentclass{article} \usepackage{lipsum} \setcounter{secnumdepth}{4} \newif\ifmoreinput \newcounter{sec} \newcounter{ssec}[sec] \newcounter{sssec}[ssec] \newcounter{parg}[sssec] \begin{document} \loop \stepcounter{section}% \stepcounter{sec}...


4

Using \ifcase...\fi conditional in advance (requires the relevant chapter prefixes to be defined in advance, of course too!) \documentclass{book} \usepackage{tocloft} \addtolength{\cftchapnumwidth}{20pt} \addtolength{\cftsecnumwidth}{20pt} \renewcommand{\thechapter}{% \ifcase\value{chapter} \or LAW% \or VNR% \or FOO% \or FOOBAR% \or ...


4

It's certainly possible: \documentclass{book} \makeatletter \newcommand{\chapterkey}[1]{% \renewcommand{\chapter@key}{#1}% } \newcommand{\chapter@key}{???} % initialize \renewcommand{\thechapter}{\chapter@key} \makeatother \begin{document} \chapterkey{LAW} \chapter{foo} \section{Problems} \section{Solutions} \chapterkey{VNR} \chapter{bar} \section{...


2

This approach may not be a good idea, LaTeX is designed to take care of the numbering for you (for example when you decide later to add a section between 1 and 2). If you want to do it anyway, a scripting language is probably the easiest way. Example in Perl: use File::Find; use Cwd; # get working directory for script $cwd1 = getcwd(); # find all tex ...


3

Adding a \strut to your first code ensures the same size. If you wanted to set the height to a lower value, you should replace \makebox with a \parbox, where you can control the height and width of the box. The syntax is \parbox[verticalPos][height][horisontalPos]{width}{text}. Example \parbox[b][.8ex][l]{.7em}{text} \documentclass[11pt]{memoir} \usepackage[...


4

For fun, here is a solution in ConTeXt. Some remarks: I use OCR-A font to match the font used in the movie. I use three shades of green. Colors are defined in the HSV colorspace and the three colors just have different saturation values. I use a TABLE for typesetting for ease of use. One could have used a simple \halign as well. For ConTeXt users, this ...


4

Here is a suggestion using the random function: \documentclass[svgnames]{report} \usepackage{tikz} \colorlet{Random0}{white} \colorlet{Random1}{green} \usepackage{kpfonts} \usepackage[explicit]{titlesec} \newcommand*\chapterlabel{} \titleformat{\chapter} {\gdef\chapterlabel{} \normalfont\sffamily\Huge\bfseries\scshape} {\gdef\chapterlabel{\...


1

This small document adds a leading zero in front of the section number and uses 15 dummy \blinddocument commands in the loop to fill up. \documentclass{article} \usepackage{blindtext} \makeatletter \let\latex@@thesection\thesection \newcommand{\padwithzero}{% 0% }% \renewcommand{\thesection}{\ifnum\c@section<10\relax\padwithzero\fi\latex@@...


0

I solved the problem using the soul package. It works just as fine as egreg's answer but lets me put the underlining higher than the standard height. \documentclass[a4paper, 11pt]{article} \usepackage{soul} \setul{1.5 pt}{.6 pt} \usepackage[explicit]{titlesec} \titleformat{\section}{\Large\centering}{}{0em}{\ul{#1}} \begin{document} \section{Very Long ...


1

Add the lstlisting counter to the reset list of the section counter with \counterwithout*{lstlisting}{section} -- the * prevents redefinition of \thelstlisting then! Saying \makeatletter \g@addto@macro\appendix{% \counterwithin*{lstlisting}{section}% } \makeatother this will automatically enable this specific style of resetting if \appendix is ...


1

The argument to \underline cannot be broken across lines. You can do it with ulem: \documentclass[a4paper, 11pt]{article} \usepackage[normalem]{ulem} \usepackage{titlesec} \titleformat{\section}{\Large\centering}{}{0em}{\uline} \begin{document} \section{Very Long very long very long very \\ long very long very long Title} Text text text \end{document}


1

This approach prevents the \refstepcounter code if it's not executed in the \tableofcontents, by using a conditional named \ifnotintoc, being set to false at the beginning of the \tableofcontents. This prevents the generation of the same label again (unless \newtest is used again after resetting of the test counter!) In the ToC stage, the already written ...


1

This can be achieved by resetting counter next to Table of Contents: \tableofcontents \setcounter{test}{0}


2

Found \setcounter{secnumdepth}{0} in apa6.cls, which will produce nothing with \ref command. For more errors with \cite, use option natbib


3

May be I’m missing something, but why don’t you use the secnumdepth counter? MWE: \documentclass[a4paper]{book} \usepackage[T1]{fontenc} % unrelated to the question, but recommended \usepackage{bookman} \usepackage{sectsty} \usepackage{lipsum} \subsectionfont{\normalfont\itshape\large} \setcounter{secnumdepth}{1} \begin{document} \...


2

Here are some conditions that seem to be met: You only use \section*. You typically have section titles that are shorter than the column width, but occasionally roll over to two lines. Roll-overs should always fit on a single line. (1) helps because it simplifies the measurement (there is no sectional number in the title). We can use xparse to redefine \...


1

A manual setup, not very convenient, by storing the chapter number and restoring it later on. (In this example, the chapter number width in the ToC should be increased, e.g. with \addtolength{\cftchapnumwidth}{5pt} from tocloft package) \documentclass{book} \newcounter{subchapterusage} \makeatletter \let\latex@@thechapter\thechapter \@addtoreset{...


3

You should use \leavevmode before the color command. This will avoid that a page break can occur between the color and the title of the section. \documentclass{scrartcl} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{xcolor} \usepackage{scrlayer-scrpage} \addtokomafont{section}{\leavevmode\color{red}} \addtokomafont{pageheadfoot}{\color{...


3

Similar to samcarter's solution, but uses \section (no argument needed): \documentclass{article} \let\oldsection\section% Store \section in \oldsection \renewcommand{\section}{% Update \section \refstepcounter{section}% Step section counter \oldsection*{Question~\thesection}}% Write a \section* with a specific header \begin{document} \section Some ...


5

Would you be happy with something like this? \documentclass{article} \newcounter{qnumber} \setcounter{qnumber}{0} \newcommand{\newquestion}{\addtocounter{qnumber}{1}\section*{Question \theqnumber}} \begin{document} \newquestion abc \newquestion cdf \end{document}


3

Note that it is not recommended to use titlesec together with a KOMA-Script class. So I will use \RedeclareSectionCommand to change the skips before and after the section titles. \enoteheading uses \section* for the note heading. So you can prepend a \RedeclareSectionCommand to get the desired result. Note that I am not sure if \enoteheading should be ...


1

Edit: Update with xassoccnt v.0.8 -- usage of cascaded suspension of counters, i.e. all counters in a counter reset list will be suspended: \documentclass{book} \usepackage{xassoccnt} \usepackage{blindtext} \setcounter{secnumdepth}{4} \begin{document} \tableofcontents \listoffigures \listoftables \CascadeSuspendCounters{chapter} \chapter{The first ...


6

At its simplest, setting the section counter to -1 will cause the next section to be 0. \documentclass{book} \begin{document} \setcounter{section}{-1} \section{text} \end{document} To change the appearance of sectioning, for example to add the subsection number by default, one needs to redefine \thesection, as well. \documentclass{article} \usepackage{...


0

The first comment has to be that shrinking titles beyond LaTeX's defaults is likely to be difficult to read or look out of place and so it's probably a better choice to rename the section. Having said that, it might be preferable to have a \sectionshort[Short Title]{Full Title} command which prints <Short Title> if <Full Title> can't fit on the ...


0

I found a following solution: \usepackage[tracking=true]{microtype} \newcommand\squeeze[1]{\SetTracking{encoding=*}{#1}\lsstyle} I can call it e.g. by: \section*{\squeeze{-75} *This is a very long title that is now being squeezed into one line*} Nevertheless, I have to say "squeeze"! and by what amount ("-75") every time. Does someone ...


1

Put the first \begin{minipage} just before \section{Imagenes}.


1

To have label and title on the same line, use the block style, and the command \filleft as the first mandatory argument (global settings): \documentclass[a4paper]{report} \usepackage[T1]{fontenc}% \usepackage{geometry}%% \usepackage{garamondx}% \usepackage{xcolor} \usepackage{titlesec} \titleformat{\chapter}[block]% {\bfseries\Large\filleft}% {\fontsize{60}...


7

The text seems to be set in two-column mode. Then the star form of the float environments use both columns at the top or bottom of the page, example: \documentclass[12pt,twocolumn]{article} \usepackage{lipsum} \usepackage[a5paper,hmargin=10mm,vmargin=10mm,includefoot]{geometry} \usepackage{xcolor} \begin{document} \begin{table} \textcolor{gray}{\rule{...


5

This feature can be added easily using an 2nd optional argument to the \section and \subsection commands, which is used for the 'status'. This does no harm if the argument is empty. \documentclass{article} \usepackage{xparse} \makeatletter \let\latex@@section\section \let\latex@@subsection\subsection \RenewDocumentCommand{\section}{somO{}}{% \...



Top 50 recent answers are included