I like it when the images in posts are centered because for me the whole post looks a little bit more professional.

Therefore I use currently the hskip command:

$\hskipXin$     % with X being some real value, e.g., .5, 1, 2, ...

But doing this all the time manually, which includes the need to find a proper X-value that somehow centers the image, isn't that satisfying. ^^

Theoretically, can you tell which method I would choose to automagically center my images?

  • 1
    $\begingroup$ I think it's by design, that images are not centred in general and the way you choose to workaround this may look odd on different browsers/devices. Here is something related on meta: meta.stackexchange.com/q/25835/260760 $\endgroup$ Commented Aug 4, 2015 at 8:23
  • $\begingroup$ not nice from the programming gods $\endgroup$ Commented Aug 4, 2015 at 9:43

1 Answer 1


@MartijnPieters Can you please tell how to align it center

@SVM-RAJESH: you cannot; there are no alignment options.

So, you have no official way of doing this. Instead;

  • Use \hspace or \hskipxin. I prefer \hspace though. It would've been heaven if MathJax supported \rule - that really gives horizontal and vertical control over "stuff" - but no cigar.
  • Use <pre>. This is inconsistent and/or ugly in some browsers.
  • Use &nbsp;. Ten times a day, before each meal. Well, I'm pretty sure we're lazier off with $\LaTeX$ shortcuts.

Now, let's resize this thing:

Using \hspace:


I used $\hspace{25ex}$; then stared at the image to figure out whether if it's centered or not$\ldots$ and then felt asleep. So figuring that out is your job.

Using <pre>



I typed 25 spaces to achieve that. If we're too lazy for \hskipxin, then yeah$\ldots$ this isn't an option.

Using &nbsp;


I don't have much to say, just that I used 48 &nbsp;s to align it like that.

So it's your choice which one to use.

  • 1
    $\begingroup$ As an alternative, you can make you pictures full width. Of course this is only possible, when you make original content or decide to resize sources from the internet. $\endgroup$ Commented Aug 4, 2015 at 23:46
  • $\begingroup$ On another note, I took a look at this answer from my android tablet's browser; the only one that actually looked centered was the \hspace version. Talk about inconsistency$\ldots$ $\endgroup$
    – M.A.R.
    Commented Aug 5, 2015 at 8:33

You must log in to answer this question.

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