I would like to automatically center a sentence within a Bclogo box; that is, I would like to place the sentence such that its center lies (technically) at the midpoint of the diagonal endpoints of the rectangular-shaped bclogo.

Based on how one might automatically center a divider in the TOC, I tried the following code:


\begin{bclogo}[couleur=red!10,  %couleur=blue!14, %couleur=blue!20, 
epBord=3.5, arrondi=0, %logo=\bcplume, %\bclampe,marge=8, 
logo= ,
%ombre=true, blur, couleurBord=blue!14, %couleurBord=blue!60,
barre=none, %barre=snake, tailleOndu=1.5
]{\hfil{This sentence is not centered.}\hfil}

which produces

enter image description here

I have noticed, surprisingly to me, that if I replace \hfil by \hfill I get the following:

enter image description here

which looks pretty much like a goof horizontal centering, but clearly, not vertically centered.

In the past, I have spent a considerable amount of time trying to center a sentence by many manual trial-and-error adjustments; and so, I would like to pose the following question.

QUESTION: How may I center a sentence in the described Bclogo such that it is automatically both vertically and horizontally centered? Also, does anyone know why \hfil does not do the job as it seems to when I have used it to center an item in a TOC: and also, why is the vertical centering so egregiously off when I use \hfill?

Thank you.

  • 1
    Wouldn't it be simpler to make this with \colorbox?
    – Bernard
    Aug 21, 2021 at 21:35
  • the content is a parbox with parfillskip \hfil so you could centre with \cemtering but if you put hfill both sides it centres, if you put hfil both sides you have 1hfil on the right because of the parfillskip. But theer is some additional fixed space on the right even if you use \centering, not sure where that comes from yet Aug 21, 2021 at 21:38
  • note the first argument that you are using is the title of the box {you currently have no content) so vertically centering it would be a bit of a mis-use. Aug 21, 2021 at 21:40
  • @Bernard Yes; but in the past I recall also having run into this kind of a problem with Bclogos of different shapes. Since I had this Bclogo handy (and also, it is easier to describe what I am looking for if a rectangular shape is used), I posted the question in with the hope that a general solution might be had. Aug 21, 2021 at 22:46

1 Answer 1


The mandatory argument to bclogo is the title. You want

  text for the box

but you first need to remove the space reserved for the title, that's inserted no matter what.






\centering This sentence is centered.




enter image description here

Without the two \vspace{1cm} instructions you'd get

enter image description here

  • Thank you kindly for this very informative answer. I was not aware of -\ht\strutbox and -\dp\strutbox prior to this. Aug 22, 2021 at 16:36

You must log in to answer this question.

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