# How to force part of a paragraph title to correctly align with right marging (using e.g. \hfill)

I would like to have a \paragraph{A paragraph title 2000} with the term '2000' aligned to the right margin. If I use \subsubsection{A subsubsection title \hfill 2000}the term 2000is correctly aligned to the right margin. Using the same reasoning for the paragraph (i.e. \paragraph{A paragraph title \hfill 2000}) will push the term 2000 to the right margin but the alignment is not perfect. There is some space left between 2000and the margin.

It may be relevant to add that I want the subsequent text to start on the next line. Hence the entire command looks like this:

\paragraph{A paragraph title \hfill 2000}  \mbox{}\\
\noindent
Here comes the text....


How can I force a right alignment? (I am using TexLive)

The following code may illustrate the problem:

\documentclass[11pt,a4paper]{article}
\begin{document}

\subsubsection{My title \hfill 2000}
Here is my text\dots

\paragraph{My title \hfill 2000} \mbox{} \\
Here goes some other text.

\end{document}


Here is the result:

• \paragraph is an inline heading so it puts horizontal space after itself before what (is intended to be) the first word of the paragraph. If you want to redefine it to be a display heading it is better to do that than to use horrible markup like \mbox{}\\  (also \noindent does nothing after \\ ) – David Carlisle Jul 23 '14 at 13:14
• Thank you for this explantation! You do have an idea/link how I would go about such a redefinition? – roschu Jul 23 '14 at 13:17
• You haven't provided any usable example in your question so it is hard but basically copy the definition of \subsubsection (or just use \subsubsection) do you really have so many levels in your document you need chapter,section,subsection,subsubsection and paragraph? – David Carlisle Jul 23 '14 at 13:22
• I have added a usable example. Unfortunately I do not know how I could change the definition in such a case. – roschu Jul 23 '14 at 13:35
• Also I forgot to add: I really need these levels; I know it looks horrible but I am just "translating" a document (not mine) from Word to Latex. – roschu Jul 23 '14 at 13:43

Change the definition of \paragraph so that it is like \subsubsection and not an inline title.

\documentclass[11pt,a4paper]{article}

\makeatletter
\renewcommand\paragraph{%
\@startsection{paragraph}{4}{\z@}%
{-3.25ex \@plus-1ex \@minus-.2ex}% the same spacing above, but negative
{1sp}%                             no space after the title
{\normalfont\normalsize\bfseries}%
}
\makeatother

\begin{document}

\subsubsection{My title \hfill 2000}
Here is my text\dots

\paragraph{My title \hfill 2000}
Here goes some other text.

\end{document}


It's necessary to use a positive value of the space below parameter, even if we want no vertical space, because a zero value or less means “inline”.