Discussion:
Center All Graphics
Chris Rackauckas
2014-10-02 20:19:17 UTC
Permalink
Hello,
I am trying to create a modification that will center all graphics
automatically. How would I go about doing this? I tried
adding \usepackage{floatrow} to the LaTeX preamble but this only centers
graphics put into floats. Any ideas?
_________________________________________________
Chris Rackauckas
University of California, Irvine
Department of Mathematics
www.chrisrackauckas.com
James Sutherland
2014-10-02 20:40:45 UTC
Permalink
Better yet, why doesn't LyX center graphics (at least in floats) by
default? It centers captions by default, so why not graphics? This
inconsistency has long annoyed me...

​James
​
Post by Chris Rackauckas
Hello,
I am trying to create a modification that will center all graphics
automatically. How would I go about doing this? I tried
adding \usepackage{floatrow} to the LaTeX preamble but this only centers
graphics put into floats. Any ideas?
_________________________________________________
Chris Rackauckas
University of California, Irvine
Department of Mathematics
www.chrisrackauckas.com
Chris Rackauckas
2014-10-02 20:43:54 UTC
Permalink
Centering the graphics in floats automatically is easy: Just add
\usepackage{floatrow}
to the preamble. I just made a module that does this and it's a quick fix
to everything. However, for this lab notebook I am making, I want to
quickly add graphics and not worry about having to center them or put them
into floats (and all of the formatting jazz that goes with it).

_________________________________________________
Chris Rackauckas
University of California, Irvine
Department of Mathematics
www.chrisrackauckas.com

On Thu, Oct 2, 2014 at 1:40 PM, James Sutherland <
Post by James Sutherland
Better yet, why doesn't LyX center graphics (at least in floats) by
default? It centers captions by default, so why not graphics? This
inconsistency has long annoyed me...
James
Post by Chris Rackauckas
Hello,
I am trying to create a modification that will center all graphics
automatically. How would I go about doing this? I tried
adding \usepackage{floatrow} to the LaTeX preamble but this only centers
graphics put into floats. Any ideas?
_________________________________________________
Chris Rackauckas
University of California, Irvine
Department of Mathematics
www.chrisrackauckas.com
Rainer M Krug
2014-10-03 11:03:25 UTC
Permalink
Post by Chris Rackauckas
Centering the graphics in floats automatically is easy: Just add
\usepackage{floatrow}
to the preamble. I just made a module that does this and it's a quick fix
to everything. However, for this lab notebook I am making, I want to
quickly add graphics and not worry about having to center them or put them
into floats (and all of the formatting jazz that goes with it).
I had a similar question, and I =rmember that I redifined the
\includegraphics - but I don't remember any details anymore.

See e.g. the thread "Re: Search and replace within figure settings?" in
this group for an example on how to include always a shadowbox - this
could be easily changed to center the included graphics.

Here the relevant extract:

--8<---------------cut here---------------start------------->8---
%%%%%%%%
% from
% http://tex.stackexchange.com/questions/70547/how-can-i-renew-includegraphics-to-always-use-shadowbox
\usepackage{graphicx,fancybox,letltxmacro}
% save the meaning of \includegraphics
\LetLtxMacro\latexincludegraphics\includegraphics
% pass the image to \shadowbox
\renewcommand{\includegraphics}[2][]{%
\shadowbox{\latexincludegraphics[#1]{#2}}}
%%%%%%%%

In addition, I used the following in the preamble to make the graphics always centered:

\renewenvironment{figure}[1][]{
\@float{figure}
\centering}
{\***@float}
--8<---------------cut here---------------end--------------->8---


Cheers,

Rainer
Post by Chris Rackauckas
_________________________________________________
Chris Rackauckas
University of California, Irvine
Department of Mathematics
www.chrisrackauckas.com
On Thu, Oct 2, 2014 at 1:40 PM, James Sutherland <
Post by James Sutherland
Better yet, why doesn't LyX center graphics (at least in floats) by
default? It centers captions by default, so why not graphics? This
inconsistency has long annoyed me...
James
Post by Chris Rackauckas
Hello,
I am trying to create a modification that will center all graphics
automatically. How would I go about doing this? I tried
adding \usepackage{floatrow} to the LaTeX preamble but this only centers
graphics put into floats. Any ideas?
_________________________________________________
Chris Rackauckas
University of California, Irvine
Department of Mathematics
www.chrisrackauckas.com
--
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982
Chris Rackauckas
2014-10-03 17:34:01 UTC
Permalink
Thanks. That worked well. However, it still shows up in Lyx as left
aligned. Is there some way to grab the graphics in Lyx to do something like
for styles? For example, for styles I know I can

Style Chapter
Align Left
End

But is there a way to instead grab any graphics object?


_________________________________________________
Chris Rackauckas
University of California, Irvine
Department of Mathematics
www.chrisrackauckas.com
Post by Rainer M Krug
Post by Chris Rackauckas
Centering the graphics in floats automatically is easy: Just add
\usepackage{floatrow}
to the preamble. I just made a module that does this and it's a quick fix
to everything. However, for this lab notebook I am making, I want to
quickly add graphics and not worry about having to center them or put
them
Post by Chris Rackauckas
into floats (and all of the formatting jazz that goes with it).
I had a similar question, and I =rmember that I redifined the
\includegraphics - but I don't remember any details anymore.
See e.g. the thread "Re: Search and replace within figure settings?" in
this group for an example on how to include always a shadowbox - this
could be easily changed to center the included graphics.
--8<---------------cut here---------------start------------->8---
%%%%%%%%
% from
%
http://tex.stackexchange.com/questions/70547/how-can-i-renew-includegraphics-to-always-use-shadowbox
\usepackage{graphicx,fancybox,letltxmacro}
% save the meaning of \includegraphics
\LetLtxMacro\latexincludegraphics\includegraphics
% pass the image to \shadowbox
\renewcommand{\includegraphics}[2][]{%
\shadowbox{\latexincludegraphics[#1]{#2}}}
%%%%%%%%
\renewenvironment{figure}[1][]{
\centering}
--8<---------------cut here---------------end--------------->8---
Cheers,
Rainer
Post by Chris Rackauckas
_________________________________________________
Chris Rackauckas
University of California, Irvine
Department of Mathematics
www.chrisrackauckas.com
On Thu, Oct 2, 2014 at 1:40 PM, James Sutherland <
Post by James Sutherland
Better yet, why doesn't LyX center graphics (at least in floats) by
default? It centers captions by default, so why not graphics? This
inconsistency has long annoyed me...
James
On Thu, Oct 2, 2014 at 2:19 PM, Chris Rackauckas <
Post by Chris Rackauckas
Hello,
I am trying to create a modification that will center all graphics
automatically. How would I go about doing this? I tried
adding \usepackage{floatrow} to the LaTeX preamble but this only
centers
Post by Chris Rackauckas
Post by James Sutherland
Post by Chris Rackauckas
graphics put into floats. Any ideas?
_________________________________________________
Chris Rackauckas
University of California, Irvine
Department of Mathematics
www.chrisrackauckas.com
--
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982
Scott Kostyshak
2014-10-02 22:00:10 UTC
Permalink
On Thu, Oct 2, 2014 at 4:40 PM, James Sutherland
Better yet, why doesn't LyX center graphics (at least in floats) by default?
It centers captions by default, so why not graphics? This inconsistency has
long annoyed me...
James
Hi James,

I don't think LyX centers captions or specifically doesn't center
graphics. From what I understand, LyX respects the class defaults,
which in my opinion is what it should do. If you are writing an
article for a journal whose document class has figures aligned to the
left, they probably would not appreciate it if LyX changed that, or
any other stylistic element. It would lead to an inconsistent journal
edition.

Best,

Scott
Chris Rackauckas
2014-10-03 01:21:48 UTC
Permalink
Hi Scott,
Where would I find the Koma-Script Book layout (is it named differently?)
and more importantly, how would I center all graphics?

_________________________________________________
Chris Rackauckas
University of California, Irvine
Department of Mathematics
www.chrisrackauckas.com
Post by Scott Kostyshak
On Thu, Oct 2, 2014 at 4:40 PM, James Sutherland
Post by James Sutherland
Better yet, why doesn't LyX center graphics (at least in floats) by
default?
Post by James Sutherland
It centers captions by default, so why not graphics? This inconsistency
has
Post by James Sutherland
long annoyed me...
James
Hi James,
I don't think LyX centers captions or specifically doesn't center
graphics. From what I understand, LyX respects the class defaults,
which in my opinion is what it should do. If you are writing an
article for a journal whose document class has figures aligned to the
left, they probably would not appreciate it if LyX changed that, or
any other stylistic element. It would lead to an inconsistent journal
edition.
Best,
Scott
Scott Kostyshak
2014-10-03 01:37:12 UTC
Permalink
Post by Chris Rackauckas
Hi Scott,
Where would I find the Koma-Script Book layout (is it named differently?)
Hi Chris,

Searching (case-insensitively) for "koma" tells me it's in the file
scrbook.layout.
Post by Chris Rackauckas
and more importantly, how would I center all graphics?
I don't know.

Best,

Scott
Continue reading on narkive:
Loading...