I have this doubt

Using lyx inside a floating I been putting the images, everything was good but then I realized something: some images are aligned in the center and others not. I don't understand because I have put the latex code \centering beside every image but it seems that this doesn't work for all the images.

enter image description here

enter image description here

Do you know what could be the problem and what can I do?

Thanks a lot.

  • Are the images it doesn't work for very wide? \centering won't help in that case, they'll just poke out on the right anyway. The boring way of fixing it is to insert some negative horizontal space by for example writing \hspace*{-1cm} in an ERT just before the image. Another way is to use \makebox as in this answer (also with ERTs. – Torbjørn T. Sep 5 '13 at 20:37
  • Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code. Many people here use LaTeX directly, so probably is better if you show the LaTeX code (View menu) or an exported MWE (File menu) from \documentclass{...} to \end{document}. – Fran Sep 5 '13 at 20:40
  • use \frame{\includegraphics{.......}} the frame will put a visible box around the image so you can see how big latex thinks it is, it may be wider than the page (in which case use [width=\textwidth] to scale it down) or it may have white space inside the frame in which case the specified bounding box for the figure is incorrect. – David Carlisle Sep 5 '13 at 20:48
  • Thanks a lot for your replays. I have been trying to control this problem with your advices. The images I'm using are not bigger that the page, actually it seems that the problem is only with the smaller images, like if the Latex code were invisible for the editor. But then I put the image in another lyx file just to prove and.. surprise!! not problem with them in a new project. Does it have any sense?, I mean, in theory the general configuration (margins, tipography...) of the editor should have effect on all the files, or not? – user2343521 Sep 6 '13 at 17:56
  • Could you create a minimal example? That is, remove as much content as you can from your document while still demonstrating the problem, then edit your question to include either the .lyx file itself or the exported LaTeX source. (A .lyx file is just plain text, so if you open it in a text editor you can just copy everything.) – Torbjørn T. Sep 6 '13 at 18:18

The captures are from a Lyx in Spanish, but the procedure must be the same in the English version, may be with different words to those that I use.

LyX method:


  1. Select with the cursor select a block of text iside the figure float but without text, including just the image (when done, you will see a cyan border around the image)
  2. Right mouse click.
  3. Select "Paragraph configuration" (or something with this meaning)
  4. Select the radio button "Center"
  5. Apply or Accept

ERT method:


  1. Put the cursor just before the image, but inside of the figure float
  2. Insert a ERT box (Ctrl+L)
  3. Write \centering

You will see the image still in the left side but will be centered in the PDF:

  • While I applaud you taking the time to write such a detailed answer, this really is just repeating exactly what has been said before. And regarding your final note, I think you're mixing center and centering. (Sorry if I sound like a grumpy old guy, that is not my intention.) – Torbjørn T. Sep 13 '13 at 21:13
  • One more answer stating the same, now with illustration. – juliohm Sep 13 '13 at 21:14
  • @TorbjørnT. Lyx write \begin{centering}, not \begin{center}, in the float. With respect to the answer, yes is the same. I started without see any answer, and I spent time making screenshots, draft and was doing other things too. I saw the others answers afer saving. That's it. If you want include the screenshots in your answer (or your own images, of course) I will delete this answer. – Fran Sep 13 '13 at 21:39
  • Wrt. to center vs. centering: I know what LyX does. As far as I know there isn't really any centering environment though, and it is center that adds vertical space, see e.g. tex.stackexchange.com/a/23653/586. (It works because LaTeX is created so that commands may work as environments, even if that is not always recommended, see e.g. this comment by David Carlisle. Oh, and I'm too lazy, so I'll just delete my answer insted. – Torbjørn T. Sep 14 '13 at 8:12
  • @TorbjørnT. You should not delete your answer, please restore it. With respect to centering environment, after all, it works, then exists. :-). Well seriously, you're absolutely right. If I remember correctly, long ago Lyx really added this vertical space (so, using center), but usually I write only plain LaTeX using \centering inside floats, hence my confusion. – Fran Sep 14 '13 at 10:15

You rarely need to insert TeX directly in LyX documents, and in fact using \centering here is inadequate.

For alignment of figures, simply right-click the paragraph where the picture is and select Paragraph settings... Choose the alignment and you're done.

  • 1
    How is it inadequate? (And by the way, I mentioned the paragraph setting in my answer as well.) – Torbjørn T. Sep 13 '13 at 20:42
  • @TorbjørnT.: Sorry, I didn't read your answer entirely. It's inadequate because LyX provides the Paragraph interface that should be used instead. I like to think of TeX insertion in LyX as a hack for problems that can't be handled in the current version. More LyX evolves, less TeX inlines in the document. – juliohm Sep 13 '13 at 20:50
  • I do sort of agree that if things can be handled (easily) via the LyX GUI, then that is the best way to do it, but I'm not sure 'inadequate' is the right word to use, at least with my understanding of it. Also, LyX adds centering as an environment inside figures, which it isn't intended as, AFAIK. – Torbjørn T. Sep 13 '13 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.