With this code you are precisely telling TeX to indent after section titles.
\makeatletter
\renewcommand\section{\@startsection {section}{1}{0mm} % name, level, indent
{3pt} % before skip
{3pt} % after skip
{\normalfont\bfseries}}
\makeatother
The parameter "before skip" should be negative for having no indentation:
\makeatletter
\renewcommand\section{\@startsection {section}{1}{0mm} % name, level, indent
{-3pt} % before skip
{3pt} % after skip
{\normalfont\bfseries}}
\makeatother
However, it's not a good idea to have fixed spacing around section titles, which don't leave flexibility to the page. Probably
\makeatletter
\renewcommand\section{\@startsection {section}{1}{0mm} % name, level, indent
{-3pt plus -2pt minus -1pt} % before skip
{3pt plus 1pt} % after skip
{\normalfont\bfseries}}
\makeatother
would be a better choice (albeit too tight, in my opinion).
Notice that LaTeX will "change sign" to the specified glue, so it's not a negative vertical spacing.
You would get a very similar result without tampering with low level commands with
\usepackage[tiny,compact]{titlesec}
so my advice is to remove the \@startsection
code, as the one provided by titlesec
is safer.
There are lots of ways to do this. A simple way using just an enumerate
environment
\begin{enumerate}
\item[5] This is the question.
\item[] This is where the answer goes
\end{enumerate}
or perhaps you want your own environment; I've posted a few different options below- take your pick, or perhaps build one based off one of them.
\documentclass{article}
\usepackage{calc}
\newcommand{\question}[1]{\item[#1]}
\newcommand{\answer}{\item[]}
\newenvironment{questionandanswer}[2]{\enumerate\setcounter{enumi}{#2-1}\item#1\item[]}{\endenumerate}
\newenvironment{anotherapproach}{\enumerate}{\endenumerate}
\begin{document}
\begin{questionandanswer}{This is the question.}{5}
This is where the answer goes
\end{questionandanswer}
\begin{anotherapproach}
\question{5} This is the question.
\answer This is where the answer goes
\end{anotherapproach}
\begin{enumerate}
\item[5] This is the question.
\item[] This is where the answer goes
\end{enumerate}
\end{document}
If you want to change the indentation of the enumerate
environment, then the enumitem
package is the most sensible way to go:
\documentclass{article}
\usepackage{calc}
\usepackage{enumitem}
\setlist[enumerate]{leftmargin=*}
Best Answer
If you don't want anything indented, it is better to load
parskip
. This sets the paragraph indentation to zero and marks paragraphs with increased vertical skip while maintaining the proper formatting of environments which use\parindent
,\parskip
etc.Alternatively, you might find it easier to use a list environment to keep formatting consistent. For example:
This basically sets up a new, specialised
pirates
list formatted in a particular way. The example looks like this: