# Redefining \section command

I'm writing a draft of my notes with Latex. They are basically definitions related to a particular concept from different sources. Therefore I have used the command \section to highlight the concept that I'm talking about.

At the same time, I would like to attach right after the title of the section the page number in which I have found the information because it helps me to find it in the bibliography later on. But in doing so, as you would expect, the text appears below the title's section.

Do you know any way to change the \section command to let me introduce some text without breaking the line?

I have seen some questions related to my post but they use shortcuts to avoid redefining the \section command (like using lists). I think that the titlesec package would help me, but I don't know how to use it. In this respect, it would be really helpful if you could help me to understand how to use it properly.

Thank you!

Edit(2): Here is MWE:

\documentclass{article}

\usepackage{titlesec}

\begin{document}

\section*{Name of the section} (page)

\paragraph*{Name of the section} (page)

\titleformat*{\paragraph}{\Large \bfseries}

\paragraph*{Name of the section} (page)

\end{document}


Edit: Regarding @Zarko comment, I would like to use the section command and do what it can be done with the paragraph one. My question it would be how to modify the section command to act as if it was a paragraph with respect to the line breaking of the line after the head of the section.

• Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Jun 21 '15 at 5:48
• Instead of section you can use \paragraph{...}. – Zarko Jun 21 '15 at 7:25
• is there a reason you can't include {\mdseries\protect\cite{...}} right in the section title? – barbara beeton Jun 21 '15 at 12:34
• @Christian Firstly, I'm not a non-native English speaker so thank you editing my typos. As I'm new in this site I don't know how to add a MWE. But I would appreciate your help in this respect. – Eduard Garriga Viudes Jun 21 '15 at 20:13
• @barbarabeeton What do you mean by including {\mdseries\protect\cite{...}}? It is for citing the bibliography? – Eduard Garriga Viudes Jun 21 '15 at 20:26

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)

\paragraph{Name of the section} (page)

\titleformat*{\paragraph}{\Large \bfseries}

\paragraph{Name of the section} (page)

\end{document}


• this is exactly what I was looking for. Thank you very much! As it was my first post, in the beginning I didn't thought that the MWE it will be that helpful to understand what I was asking for. – Eduard Garriga Viudes Jun 24 '15 at 2:41
• @EduardGarrigaViudes It makes a big difference. It is so easy to think that because you understand what you mean, it will be clear to everyone else. (I say 'you' but I mean 'me', of course. I constantly forget this in all kinds of contexts - not just on TeX.SE :(.) – cfr Jun 24 '15 at 2:48

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}

• Why not just use \paragraph in this case? I thought the question was precisely how not to have to use something other than \section. But I am not, to be honest, at all clear what the question is still. So this may be the perfect answer to it. – cfr Jun 24 '15 at 0:05
• @Andrew your answer is quite simple and I really liked it. Sorry everyone else if I wansn't quite clear about what I was asking for. – Eduard Garriga Viudes Jun 24 '15 at 2:37