# Display square brackets in the output macro definition

I am using cite package to manage citations (compressing many citations, superscripting). And I am trying to use the package's \citen command to display the in-line version of a reference, but within square brackets (in the answer to @Steven B. Segletes's "self-referential-ness": so as not to have to put square brackets all the time when I need them).

I came to this (as suggested by @Steven B. Segletes and @TeXnician I removed mathmode):

\newcommand{\citin}[1]{%
[\citen{#1}]%
}%


Although I get no errors nor warnings and the output looks nice, I would like to know if this is the proper way to define square brackets within macro, if else, please tell, I am new in macro definitions. I also worry if those brackets will keep together with the number inside on line break.

Is this also the way I should follow to get square bracketed superscripted output?

EDIT: MWE

\documentclass[11pt,a4paper]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[super,nobreak]{cite}% cytowania w indeksie górnym, bez łamania wyliczeń cytowanych
\newcommand{\citin}[1]{% użyj \citin do cytowania w linii (np. Wg [1] sprawa ma się tak...)
[\citen{#1}]%
}%
\begin{document}%
Or maybe not all from \citin{kowalski}.

\begin{thebibliography}{9}

\newblock Title 1.
\newblock {\em APL}, 1:1–2, 2015.

\bibitem{kowalski}
D. Kowalski.
\newblock Title 2.
\newblock {\em JPC}, 2:2–5, 2017.
\end{thebibliography}
\end{document}


• I don't believe math mode is needed for brackets, so that [\citen{#1}] should be sufficient. However, your definition is self-referential. – Steven B. Segletes Oct 13 '17 at 9:53
• You still do not need the math mode for the cite. – TeXnician Oct 13 '17 at 9:58
• OK. This works as well, but is it really the way I should do to add brackets in superscript also? Or should I somehow redefine the \cite command? – Olek Tomkowski Oct 13 '17 at 10:01
• You should provide us with a minimum working example (code beginning with \documentclass, ending with \end{document}) in which you use the macros as you are intending to use them. That will help us see what exactly it is you are trying to accomplish, and may help us give you the best answer. – Steven B. Segletes Oct 13 '17 at 10:05
• Here it is now. I mean to have the "1" as superscripted [1] to work with cite package – Olek Tomkowski Oct 13 '17 at 10:36

To answer the direct question, maybe this?

\documentclass[11pt,a4paper]{article}
\usepackage[english]{babel}
\usepackage{blindtext,amsmath}
\usepackage[super,nobreak]{cite}% cytowania w indeksie górnym, bez łamania wyliczeń cytowanych
\newcommand{\citin}[1]{% użyj \citin do cytowania w linii (np. Wg [1] sprawa ma się tak...)
\unskip$^\text{[\citen{#1}]}$%
}%
\begin{document}%
Or maybe not all from \citin{kowalski}.

\begin{thebibliography}{9}

\newblock Title 1.
\newblock {\em APL}, 1:1–2, 2015.

\bibitem{kowalski}
D. Kowalski.
\newblock Title 2.
\newblock {\em JPC}, 2:2–5, 2017.
\end{thebibliography}
\end{document}


However, the cite manual gives the explicit example of how to make \cite place superscripted citations in brackets, if this would be preferable.

\documentclass[11pt,a4paper]{article}
\usepackage[english]{babel}
\usepackage{blindtext,amsmath}
\usepackage[super,nospace,compress,nobreak]{cite}% cytowania w indeksie górnym, bez łamania wyliczeń cytowanych
\makeatletter
\renewcommand\@citess[1]{\textsuperscript{[#1]}}
\makeatother
\begin{document}%
Or maybe not all from \cite{kowalski}.

\begin{thebibliography}{9}

\newblock Title 1.
\newblock {\em APL}, 1:1–2, 2015.

\bibitem{kowalski}
D. Kowalski.
\newblock Title 2.
\newblock {\em JPC}, 2:2–5, 2017.
\end{thebibliography}
\end{document}


• I guess this answers my question, but what is the unskip here for if you could tell me? – Olek Tomkowski Oct 13 '17 at 11:01
• @OlekTomkowski \unskip removes any prior space, so that there is no gap prior to the superscript, which had been introduced when you leave a space before the invocation of \citin, as in not all from \citin{kowalski} One could have alternately invoked as not all from\citin{kowalski} and then the \unskip would be unnecessary. – Steven B. Segletes Oct 13 '17 at 11:10
• Thank you, now I see that with your solution I can also remove the [super] option from cite, thus not having to use the inline version which natively has square brackets. – Olek Tomkowski Oct 13 '17 at 11:14
• @OlekTomkowski Please see the supplement to my answer, if that is even better. – Steven B. Segletes Oct 13 '17 at 11:23
• It seems even better, but I'd rather not re-define things within the package if I don't have to. Now I use the previous solution having defined mnemonic citeup when I want it up and with brackets. I find it quite reasonable for now :) – Olek Tomkowski Oct 13 '17 at 14:11