2

In the text environment, I want to centering some stars between paragraphs. I know I can do this by

 \begin{center}
    \color{cyan}\makebox[5cm]{* * * * * * * * * * * * * * * * * * * *}
 \end{center}

but the vertical space is hard to control. I do not know why the following does not work

$\centering{\color{cyan}\makebox[5cm]{* * * * * * * * * * * * * * * * * * * *}}$

The result will not in the center.

3
  • 1
    \centering{$\color{cyan}\makebox[5cm]{* * * * * * * * * * * * * * * * * * * *}$} does it for me... note that $ structurally is an environmentlike structure where a lot of macros don't work...
    – AndiW
    Dec 5, 2018 at 13:33
  • why not for me ?
    – thone
    Dec 5, 2018 at 13:35
  • did you put the \centering outside of the $? If that still does not work you should provide a MWE and tell us which latex you use
    – AndiW
    Dec 5, 2018 at 13:38

3 Answers 3

2

Try

\documentclass{article}
\usepackage{color}
\begin{document}
\makebox[\textwidth][c]{$\color{cyan}\makebox[5cm]{* * * * * * * * * * * * * * * * * * * *}$}

nice
\end{document}
5
  • 1
    \centering does not take an argument, this will center the rest of the document.
    – TeXnician
    Dec 5, 2018 at 13:47
  • 1
    eventualy \centerline{$\color{cyan} ....$}
    – Zarko
    Dec 5, 2018 at 13:53
  • @TeXnician oups - sorry. fixed.
    – AndiW
    Dec 5, 2018 at 13:54
  • Thanks, friends. Zarko and AndiW . Your codes both work!
    – thone
    Dec 5, 2018 at 14:03
  • You're definitely short a \noindent. Also, there seems to be no need for the internal \makebox or switches to math mode...
    – Werner
    Dec 12, 2018 at 7:55
2

How about this?

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{xcolor}
\usepackage{lipsum}
\newcommand{\cstars}{\vskip 1.2ex\noindent\par\makebox[\linewidth]{\color{cyan}* * * * * * * * * * * * * * * * * * * *}\par}

\begin{document}

\lipsum[2]
\cstars
\lipsum[11]

\end{document} 

enter image description here

3
  • No need to use [1][20] - it's not used in the definition of \cstars
    – AndiW
    Dec 12, 2018 at 0:18
  • That's. I guess I copied an initial version with the number of stars as an optional argument, then decided it was unnecessary, and forgot to remove the arguments. Thanks for pointing it!
    – Bernard
    Dec 12, 2018 at 0:24
  • :) you're welcome...
    – AndiW
    Dec 12, 2018 at 0:26
1

A simple centred paragraph:

enter image description here

\documentclass{article}

\usepackage{xcolor}
\usepackage{lipsum}

\newcommand{\stars}{%
  \par
  \nobreak
  {\centering\color{cyan}\raisebox{-.7ex}[0pt][0pt]{* * * * * * * * * * * * * * * * * * * *}\par}%
}

\begin{document}

\lipsum[2]

\stars

\lipsum[2]

\end{document} 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .