2

My goal is as stated in the question title. There are other questions addressing this, but the answers selected, as best I can tell, don't get along with my other existing code, which is summarized below.

\documentclass[11pt]{article}
\usepackage{amsmath,amsthm,titlesec}
\numberwithin{equation}{section}
\newcommand{\periodafter}[1]{#1.}
\newcommand{\presectionskip}{-1\baselineskip}
\newcommand{\postsectionskip}{0.3\baselineskip}

\makeatletter
    \renewcommand{\section}{\@startsection
        {section}{1}{0mm}%% name, level, indent
        {\presectionskip}% % beforeskip
        {\postsectionskip}% % afterskip
        {\normalfont\LARGE\bfseries}}% % style
    \renewcommand{\subsection}{\@startsection
        {subsection}{2}{0mm}
        {\presectionskip}
        {\postsectionskip}
        {\normalfont\Large\bfseries}}
    \renewcommand{\subsubsection}{\@startsection
        {subsubsection}{3}{0mm}
        {\presectionskip}
        {\postsectionskip}
        {\normalfont\normalsize\bfseries}}
\makeatother

%\usepackage[font=bf]{caption}
%\titleformat{\section}{}{\thesection.}{1ex}{\periodafter}
%\titleformat{\subsection}{}{\thesubsection.}{1ex}{\periodafter}
%\titlelabel{\thetitle.\quad}

\begin{document}
\section{Good section}\label{sec:refl}
\subsection{Superior subsection}\label{tableworks}
\subsubsection{This, the best of all subsections}
\end{document}

Thanks for any ideas on how to get this to work.

jdc
  • 1,245

1 Answers1

2

The solution provided here works perfectly. Do you have concerns about getting a dot in references as well?

% arara: pdflatex

\documentclass[11pt]{article}
\usepackage{titlesec}
\newcommand{\presectionskip}{-1\baselineskip}
\newcommand{\postsectionskip}{0.3\baselineskip}
\makeatletter
\renewcommand{\section}{\@startsection
    {section}{1}{0mm}%% name, level, indent
    {\presectionskip}% % beforeskip
    {\postsectionskip}% % afterskip
    {\normalfont\LARGE\bfseries}}% % style
\renewcommand{\subsection}{\@startsection
    {subsection}{2}{0mm}
    {\presectionskip}
    {\postsectionskip}
    {\normalfont\Large\bfseries}}
\renewcommand{\subsubsection}{\@startsection
    {subsubsection}{3}{0mm}
    {\presectionskip}
    {\postsectionskip}
    {\normalfont\normalsize\bfseries}}
\renewcommand{\@seccntformat}[1]{\csname the#1\endcsname.\quad}
\makeatother
\usepackage{blindtext}

\begin{document}
    \section{Good section}\label{sec:refl}
    \subsection{Superior subsection}\label{tableworks}
    \subsubsection{This, the best of all subsections}
    \blindtext
\end{document}

enter image description here

LaRiFaRi
  • 43,807
  • I ... thought I'd tried all of those. I definitely tried the first component of the egreg answer, but obviously failed to try the second. :/ But thank you so much! What do you mean about references? – jdc Dec 15 '14 at 08:02
  • @jdc regarding egregs answer, you will get a dot as well, when you use some \ref or similar. Makes sense to have it like this, in your case. But you have to consider that "chapter 1. is showing..." could be a bit difficult to read especially, if the dot is set at the end of a line. – LaRiFaRi Dec 15 '14 at 09:47
  • I thought that was what you meant, but for whatever fortunate reason, that's not happening to me; my document doesn't have excess dots after \Crefs. I tried a \ref as well to check, and there was no dot. – jdc Dec 15 '14 at 10:04
  • @jdc oh sorry, I mixed it up. There will be no period, you are right. If you want one, you have to use one of the other answers. I would recommend titlesec for all this stuff. – LaRiFaRi Dec 15 '14 at 10:09
  • I am using titlesec, although I don't remember what I'm using it for. That's the danger with understanding as little as I do and adapting advice one finds online, I suppose. – jdc Dec 15 '14 at 10:15