MIME-Version: 1.0 Content-Location: file:///C:/D872B2F3/tidbits.htm Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="us-ascii" Fun4example - a tutorial for dummies - Richard Seto 7/20/2004

reference books

Run= ning Linux  and Practical C++  Both published = by OReilly

A l= ink to some of the books is here

htt= p://www.hk8.org/old%5Fweb/

 

If = you are part of some consortium (is BNL??- the UC is as well as many other universities)

http://safari.oreilly.com/

and look at Practial C++, as well as lots of other books.

 

ldd

to<= /span> find out the libraries a libr= ary references

ldd /afs/rhic.bnl.gov/phenix/PHEN= IX_LIB/sys/i386_redhat80/new.4/lib/libfun4allfuncs.so

<lots of output>

 

c++filt

demangle C++ symbol =

c++filt _ZNK7TObject7DoErrorEiPKcS1_P= c TObject::DoError(int, char const*, char const*, char*) const

 

nm – find out the dependencies in an object file

 

to install into your directory

autogen.sh -–prefix=3D$MYINSTALLDIR

configure --prefix=3D$MYINSTALLDIR

 

To make nice eps from gif (or jpeg etc)

m= ake a gif

t= hen go to unix

 

imgtops -3 picture.gif > picture.eps

 

-3 means level 3 postscript

d= efault is level 2

 

This compresses stuff nicely

 

g= et imgps from

http://imgtops.source= forge.net/

---------------------= ----------------------

OK now to build imgtops on cygwin its a pain

1) get python in cygwin

2) you need to build the python imaging library PIL

t= o do this

  a) rebase the system

http://www.tishler.ne= t/jason/software/rebase/rebase-2.3.README

g= et the tar file and bunzip and untar it

  b) then= downliad the PIL library etc as in the following=

http://www.cygwin.com= /ml/cygwin/2003-06/msg01121.html

I had to duplicate th= e the X11 directory to /usr/include/X11

Also see the followin= g

http://www.talkaboutp= rogramming.com/group/comp.lang.python/messages/312660.html

3) then get imgtops and build it

 

   Another way – use conv= ert (I have had some trouble as convert seems not to make as small an eps file as one would like – e.g. the lanl archive –

May= be I don’t know the switches – rich)

 

Hi Ric= h,

&= nbsp;

I pres= ume you are planning to add this to your "tips and tricks" book.=

&= nbsp;

I didn= 't realize this is still a problem. I always use the swiss= army knife of image formats, the Imagemagick toolbox= . The "convert" utility will convert anything to anything,  gif to eps for example, or anything to eps for that matter= . IM is a bit more readily available. It can do a whole lot more - you can make animated gifs, automate the thumbnail generation  from your fot= o album, automatically annotate images with, say, a date or some text, crop a= nd transform. I have yet to see a transformation that you cannot accomplish, a= nd, more importantly, script and so capture for re-use. It's at http://www.imagemagick.org. Just d= o

&= nbsp;

convert xx.gif xx.eps<= /span>

&= nbsp;

That's= it.

&= nbsp;

Now si= nce with such a gif -> eps conversion you have t= he original gif (or jpg, or any other) file availab= le, it's a good opportunity to make an EPS with a preview that you can import i= n, say, Powerpoint. This is where epstool comes in handy. You may recall my root macro "eps= save.C"

that we us= e to make eps files with a high-quality preview in m= uch the same fashion. Where you start out with a gif and convert it to EPS, the root macro saves the primary graphic in both gif and e= ps, then we use epstool = to combine the two into an EPS deluxe.

&= nbsp;

The ma= cro tends to disappear from $ROOTSYS/macros once in a while, I have a copy in my RCF home dir; I attach it here for your convenience.

[NOTE – for the tidbits readers – I put epssave.= C in this area]

&= nbsp;

epstool is installed in RCF and is available at h= ttp://www.cs.wisc.edu/~ghost/gsview/epstool.htm

&= nbsp;

Fire u= p root and try this:

&= nbsp;

> <= span class=3DGramE>root [0] .L epssave.C=

> r= oot [1] TH1F *x =3D new TH1F("test","test", 32,0,10) root [2]

> <= span class=3DGramE>x->Draw();

> &= lt;TCanvas::MakeDefCanvas>: created default TCanvas with name c1 root

> [= 3] epssave(c1,"rich.eps"); Info in <TCanvas::Print>: GIF file <= /o:p>

> /tmp/eps_29605.gif has been created Info in <TCanva= s::Print>: eps file

> /tmp/eps_29605.eps has been created root [4] .q

&= nbsp;

The ca= ll takes the pointer to the canvas (c1) and a file name. The macro will show y= ou how to do this outside of root. It also uses convert internally.=

 

To remove a CVS lock

 

cd $CVSROOT/../.cvslocks/

&nb= sp;

..navigate to your directory...

&nb= sp;

rm the loc= kfiles you left dangling.

&nb= sp;

Tom=

&nb= sp;

Anthony Denis Frawley wrote:

&nb= sp;

>Hi A= ll,

> 

>     Can someone please remind me where I can find a CVS lock file so that

>I can remove it?

 

GDB hints

For starters on gdb go here: 
ht=
tp://www.hk8.org/old_web/linux/run/ch14_01.htm
 
If you debug code once in a while, you're probably (way too) famil=
iar
with the long time it takes for g=
db to read in the symbols from the huge
number of shared libraries we use.  Here's how to disable the automatic
reading of all those symbols and only read them in for=
 the libraries
you're interested in.=
  Put this in your ~/.gdbinit file (or type it at
the gdb prompt before you load any files):

 

set auto-solib-=
add off

 

and then type this for the libraries you ar=
e interested in

 

share REGEX

 

where REGEX is a regular expression that ma=
tches the libraries you
want.  So=
mething like

 

share cgl

 

would load the symbols for libcgl.so.  It wou=
ld also load the libraries
for libcglfoobar.so and an=
ything else that matched the regular
expression "cgl"=
.  This can be a big timesaver=
.

 

C++ questions

Hi folks,

 

Q: What's the difference between

 

void foo(const =
int & i);

 

and

 

void bar(const int i); ?

 

A: The "const" in the declaration of bar=
() is redundantly superfluous.


By default, C++ passes arguments by va= lue, meaning that a copy is made of the argument and the subroutine then operate= s on that copy. In the second case, it's redundant to declare "i" const because bar(= ) just can't possibly change the value of "i"= ; as it appears in the calling routine. That's because bar(<= /span>) is operating on a copy of "i", so the original "i" is perfectly safe.

In the declaration of foo(), however, the = const has some real effect. In foo(), the default "pass-by-value" mechanism is replaced with a Fortran-like "pass-by-reference". That means that= foo() operates on the very same "i" that the calling routine uses. If foo() changes "i" t= hen it is also changed in the calling routine.

We have a lot of this in our code. On = picky compilers, for instance the OSF compiler, these constructs generate warnings like crazy. Pages and pages and pages of them.

Here's a command that does a pretty go= od job at finding these. A few false positives and a few false negatives, but not = too bad. Cut and paste and hit return. Then edit your code.

find $OFFLINE_MAIN/include -name '*.h*' -ex=
ec \
egrep -Hn '\([^)]*const *[^&*]+[),]' {} \; | \
grep -v gsl | grep -v CLHEP | grep -v b=
oost | \
grep -v _ref | grep -v oo

 

EMACS additions for c++

 

I think it might be worthwhile revisiting the topic of coding standard=
s, but as a prelude to that
particularly religious discussion, here are a couple o=
f utilities for emacs that I've whipped up to
help.  Just co=
py the stuff below into your ~/.emacs file and restart emacs.  Visit a header file,
type "C-c 1" and the first function will wra=
p the body of that file in a "#ifdef ... #endif" bl=
ock
to
prevent multip=
le inclusion.  Visit any C/C++=
 source file, and each time you type "C-c 2", the second
function will step a little further through your sourc= e code and offer simple suggestions for how
you might make it more maintainable (e.g., add a pair =
of braces here, add a trailing ".0" to that
number there - that sort of thing).  Luckily for me, we don't have any coding standa=
rds defined for
lisp!
 
Enjoy,
Dave
 
(defun c-cleanup ()
  (interactive)
  (let ((here))
    (catch 'foo
      (while 
&nbs=
p;         (re-search-forward 
"\\(^[\\t ]*\\(if\\|while\\|else\\|for\\)\\b\\|[^a-zA-Z][0-9]\\.[^0-9]\\|[^0-9]\\.[0-9]\\)" 
<= pre>        (point-max) t)
        (if (not (c-in-literal))
          &n=
bsp; (progn 
        &nb=
sp;     (setq here (point))
      &nb= sp;       (cond ((progn
   =
;            &n=
bsp;       (goto-c=
har (match-beginning 0))
=
            &nb=
sp;          (looking-a=
t "^[\\t ]*for\\b"))
          &nb=
sp;      &=
nbsp;   (progn
        &nbs=
p;            &=
nbsp; (c-end-of-statement)
           =
            (=
c-end-of-statement)
           =
            (=
re-search-forward ";" (point-max) t)
      &nb= sp;            =     (if (< (c-most-enclosing-brace (c-parse-state)) here= )
     =
                   &=
nbsp;  (progn 
        &nb=
sp;            =
        (end-of-line)
            &=
nbsp;           &nbs=
p;    (message "Add {}'s around this statement")
     &nbs=
p;            &=
nbsp;          (throw 'foo t)))))
      &nbs= p;             = ((progn
        &nbs=
p;            &=
nbsp; (goto-c=
har (match-beginning 0))
=
            &nb=
sp;          (looking-a=
t "^[\\t ]*\\(if\\|while\\|else\\)\\b"))
<=
span style=3D'mso-spacerun:yes'>       &=
nbsp;           &nbs=
p; (progn
        &nbs=
p;            &=
nbsp; (re-search-forward ";" (point-max) t)
      &nb= sp;            =     (if (< (c-most-enclosing-brace (c-parse-state)) here= )
     =
            &nb=
sp;         (progn 
        &nb=
sp;            =
        (end-of-line)
            &=
nbsp;           &nbs=
p;    (message "Add {}'s around this statement")
     &nbs=
p;            &=
nbsp;          (throw 'foo t)))))
      &nbs= p;             = ((progn
        &nbs=
p;            &=
nbsp; (goto-c=
har (match-beginning 0))
=
            &nb=
sp;          (looking-a=
t "[^a-zA-Z][0-9]\\.[^0-9]")=
)
     =
            &nb=
sp;   (progn
        &nbs=
p;            &=
nbsp; (end-of-line)
            &=
nbsp;          (message "Add a trailing `.0' to this  number")
         &nb=
sp;            =
 (throw 'foo t)))
=
       =
             ((progn
        &nbs=
p;            &=
nbsp; (goto-c=
har (match-beginning 0))
=
            &nb=
sp;          (looking-a=
t "[^0-9]\\.[0-9]"))
            =
;         (progn
        &nbs=
p;            &=
nbsp; (end-of-line)
            &=
nbsp;          (message "Add a prefix `0.' to this number")<=
/pre>
     &n=
bsp;            =
;     (throw 'foo t)))))))
<= pre>      &n= bsp; (message "Everything looks OK!"))))
 
(defun c-include-buffer-onc=
e (&optional buffer)
  =
(interactive)
  (save-excursion
    (let ((s (buffer-name buffer)))
         (while (string-match "\\." s)
        =
;   (setq s (replace-match &quo=
t;_" t t s)))
&nb=
sp;        (setq s (concat "__" (upcase s) "__"))
         (<=
span
class=3DSpellE>goto-c=
har (point-min))
 &n=
bsp;       (insert "#ifndef "=
;)
     =
;    (insert s)
&=
nbsp;        (newline)
         =
(insert "#define ")
         (=
insert s)
&=
nbsp;        (newline)
         =
(goto-c=
har (point-max))
 &n=
bsp;       (newline)
         =
(insert "#endif /* &qu=
ot;)
    &nb=
sp;    (insert s)
&=
nbsp;        (insert " */&qu=
ot;))))
 
(add-hook 'c-mode-common-hook
         &nb=
sp;   '(lambda ()
            =
    (define-key c-mode-map "\C-c1"  'c-include-buffer-once)
        &nb=
sp;       (define-key c++-mode-map "\C-c2"  'c-cleanup)))
 
 

 

More – make a c++ thing pretty – needs astyle

  You can= get astyle from astyle.sourceforge.net

If you add the lines below to your ~/.emacs file and restart emacs, you'll pick up a couple= of new key bindings when you edit C or C++ code. Mark a region and type "= C-c r" to use "astyle" to reformat t= hat chunk of code, or just type "C-c b" to run a= style on the whole buffer. Astyle is a source code formatting program and it does a respectable job on C++ - much better than = the current version of GNU indent which gets confused by all the angle bracket business of templates. The built-in emacs comma= nd "indent-region" only adjusts the leading whi= tespace of each line - astyle will do more than that. <= span class=3DSpellE>Astyle is available on all the RCF machines as /opt/<= span class=3DSpellE>phenix/bin/astyle.

(defvar astyle-command "astyle -p --style=3Dgnu")

 

(defun astyle-region (start end)
  "Run astyle on region, formatting it in a pleasant way.&qu=
ot;
  (interactive "r")
  (save-excursion
    (shell-command-on-region start end astyle-command nil t)
&n=
bsp;   (indent-region start end nil)))

 

(defun astyle-buffer ()
  "Run astyle on whole buffer, formatting it in a pleasant w=
ay."
  (interactive)
&=
nbsp; (save-excursion<=
/span>
&=
nbsp;   (astyle-region (point-min) (point-max))))

&n= bsp;

(add-hook 'c-mode-common-hook
             '(lambda =
()
        &=
nbsp;      (define-key c-mode-map "\C-cr=
"  'astyle-region)
            =
;   (define-key c-mode-map "\C-cb=
"  'astyle-buffer)
            =
;   (define-key c++-mode-map "\C-=
cr"  'astyle-region)
            =
;   (define-key c++-mode-map "\C-=
cb"  'astyle-buffer)))

 

Isnt this part of the cleanup?

 

For those code-jocks that use emacs, here'=
s an updated version of a little
widget I first wrote back when MJT was learning Fortra=
n IV.  Drop these lines
<= pre>into your ~/.emacs and you= should be able to hit "C-c 1" when editing a header
file to insert a prophylactic set of #ifdef's at the top and bottom. 
Carpal-tunnel-be-gone.  I've strengthened the regexps to handle the case of
editing a duplicate buffer or one being edited over efs (aka ange-ftp to the
old-school crowd).
 
;;; start here ...
 
(defun c-include-buffer-onc= e ()
  (interactive)
  (save-excursion
    (let ((s 
&nb=
sp;          (concat "__"
        &=
nbsp;         (upcase 
        &=
nbsp;          (substring 
&=
nbsp;           &nbs=
p;      &n=
bsp;(buffer-name (current-buffer)) 0 
        &=
nbsp;           (string-match "[<@$]" (b=
uffer-name (current-buffer))))) 
        &=
nbsp;         "__")))
          
      (while (string-match "\\." s)
        (setq s (replace-match &quo=
t;_" t t s)))
 
      (goto-c=
har (point-min))
 &n=
bsp;    (insert "#ifndef "=
;)
     =
; (insert s)
&=
nbsp;     (newline)
      (insert "#define ")
      (insert s)
&=
nbsp;     (newline)
      (goto-c=
har (point-max))
 &n=
bsp;    (newline)
      (insert "#endif /* &qu=
ot;)
    &nb=
sp; (insert s)
&=
nbsp;     (insert " */"))))
=
 
(add-hook 'c-mode-common-hook
          '(lambda ()
             (define-key c-mode-map "\C-c1"  'c-include-buffer-once)
             (define-key c++-mode-map "\C-c1"  'c-include-buffer-once)))
 
;;; ... OK, that's enough

 

Hi all,

 

How about a little tutorial on sorting?  We all do it, so we might as well = do it well.  Let's use an STL algori= thm to sort some numbers.  You may be thinking, "Oh no, I'm gonna have to use a = vector or dqueue or some other crazy thing I've never = heard of."  Don't panic.  Here's an example of how to sort an old-fashioned *array* of numbers:

 

#include <iostream><= /p>

#include <algorithm>

 

const = int N =3D 5;

double a[N] =3D {2.1, 0.1, = 4.1, 3.1, 8.1};

 

int

main()

{

    std::sort(a, a + N);

 

    for (int i =3D 0; i < N; i+= +)

      {

        std::cout << a[i] &= lt;< std::endl;

      }

}

 

That's not that hard, right?  Sometimes, you want to sort an arr= ay based on the values in another array - you know, produce an array of index values.  A simple way to do th= at is to write a tiny class that holds two

values: the index value and= a way to get a value from the other array.

Like this:

 

#include <iostream><= /p>

#include <algorithm>

 

const = int N =3D 5;

double a[5] =3D {2.1, 0.1, = 4.1, 3.1, 8.1};

 

struct= tinyClass

{

   <= span class=3DSpellE>int i= ;

   <= span class=3DSpellE>bool operator<(const tinyClass& I) const

   {=

   &nb= sp; return a[i] &= lt; a[I.i];

   }=

};

 

bool

print(const tinyClass &i)

{

   <= span class=3DSpellE>std::cout << "a[" << i.i << "] =3D " <&l= t; a[i.i] << std::endl; = }

 

int

main()

{

   <= span class=3DSpellE>tinyClass I[N];

   <= span class=3DGramE>for (int i =3D 0; i < N; i+= +) {I[i].i =3D i;}

   <= span class=3DSpellE>std::sort(I, I + N);

   <= span class=3DSpellE>std::for_each(I, I + N, print);

}

 

This code makes an array of "tinyClass", fills it with stuff, and sorts it.  <= /span>Easy.  Th= is code also makes a couple of other points: one, don't be afraid of making tiny li= ttle classes that are only used in one place (not all classes are worthy of a separate header file and all that); and two, I assume that people know that "struct" is just like "class&quo= t; except that everything in a struct is "public" by default.

 

Another way to do the same thing is to use the STL "pair" class, a small class which just holds two different things.  If you sort a collect= ion of pairs, the sort algorithm uses the first element of the pair to do the sort= ing, so we put the values we want to use for sorting there.

Here's an example with all the fancy stuff you might h= ope for:

 

#include <utility>

#include <vector>

#include <iostream><= /p>

#include <algorithm>

 

using namespace std;

 

const = int N =3D 5;

double a[5] =3D {2.1, 0.1, = 4.1, 3.1, 8.1};

 

bool

print(const pair<double,= int> &i)

{

   <= span class=3DSpellE>cout << "a[&quo= t; << i.second << "] =3D " &= lt;< i.first << endl; }<= /p>

 

int

main()

{

   <= span class=3DGramE>vector<pair<double, int> > v;

   <= span class=3DGramE>for (int i =3D 0; i < N; i+= +)

   &nb= sp; {

       pair<double, int> p(= a[i], i);

       v.push_back(p);

   &nb= sp; }

   <= span class=3DGramE>sort(v.begin(), v.end());

   <= span class=3DSpellE>for_each(v.begin(), v.end(), print= );

}

 

The next time you need to sort something, don't fret, = it's simple.

 

Dave

 

Hi muonistas,

 

May I suggest that some enterprising muon'er recraft the little utility function MUTOO::SQUARE?  It's one of th= ose things that seems like a good idea at first glance - but isn't.  Here's how it's implemented now:

 

double MUTOO::SQUARE(double= x) { return x*x; }

 

Simple enough, but there are sever= al problems with this.  Fi= rst it passes its argument by value, not by reference.  This results in a

(minor) performance hit of = a few percent.  Not that big a deal,= I admit, but why throw away cycles needlessly?  Here's a version that fixes that:<= /p>

 

double MUTOO::SQUARE(double &x) { return x*x; }

 

The main problem, however, is that it is written for a single, fixed type argument: a double.&nbs= p; If you call this function with a float (which is= done all over the place), the compiler has to insert code to do the float to dou= ble conversion, and then it probably has to do the reverse to capture the result too.  That's ridiculous= ly slow.

 

The usual idiom for this sort of thing,

 

template <typename T>

static inline T

sqr(const T &x)

{

   <= span class=3DGramE>return x * x;

}

 

it about *ten* times faster (compared to calling the original version with a float argument).  In the kind of code we write, squa= ring and square-rooting are very common operations, so this should be fixed.

 

 

 

Notes on jobs sizes:

 

Hi folks,

 

How can I say this delicately?  Some analysis pro= grams are just too damn big to run on the computers in the RCF.  In fact, they're too damn big to r= un on most any computer you're likely to find.&n= bsp; I've cc'ed this note directly to a few habitués of the mile-high RAM club.=   The machines in the RCF have 1 GB of memory.  They are set up to run two batch j= obs.  If you have a job that uses a lot = more than 500 MB (more is OK, a lot more is not so OK) then the machine will just degenerate into a useless room heater doing a slow tho= razine shuffle as it swaps pages in and out and in and out.

 

The jobs I'm talking a= bout are using 3 GB of memory.  Not= 600 MB or 900 MB or even 1 GB.  3 = GB.

 

It's probably as simpl= e as some otherwise useful array that has accreted a few new dimensions.  Or maybe there's a nasty memory leak.  I don't know.

 

The problem is that the machine becomes useless not just for the person who submitted a big, big, b= ig job, but also for the other person whose batch job had the misfortune to fi= nd itself on the same machine.

 

Dave=

 

> Hi Dave

> Is there an easy = way for us to see this in our batch jobs?

> -r

 

Hi Rich,

 

D= idja look at the options f= or "bjobs"?

 

"The  -l  option  displays  the following additional informati= on:

   project name, job command, c= urrent working directory on the sub-mission  host,  pending  and  suspending  reasons,  job  status, resource usage, resource usage limits information."

 

So, to take one of Hub= ert's current jobs as an example:

 

 

rcas2078% bjobs -r -u = hubert -q phenix_cas | tail -1

379945  hubert  RUN   phenix_= cas rcas2067    rcrs2125=     AuAu114836 Mar

18 18:11

rcas2078% bjobs -l 379945

 

[ = ... = buncha blah, blah, blah elided ... ]

 

Thu Mar 24 11:37:06: Resource usage collected.

        =             &nb= sp; The CPU time used is 11399 seconds.

        =             &nb= sp; IDLE_FACTOR(cputime<= /span>/runtime):   0.04

        =             &nb= sp; MEM: 427 Mbytes;  SWAP: 2035 Mbytes;  NTHREAD: 5

        =             &nb= sp; PGID: 1864;&nbs= p; PIDs: 1864 1867 1868 1869 1870

 

 

There ya go.  2GB o= f swap.  [RKS note – 2GB is too big]<= o:p>

 

Here I check a jobs of mine

 

rc= as2077 /direct/phenix+data08/seto/run4/cabana/Out % bjobs -l | more

 

Job <529197>, Jo= b Name <Outewg47435>, User <seto>, Project <default>, Status <RUN>, Queue <phenix_cas>, Job Prio= rity <50>, Command </phenix/data08/seto/run4/cabana/jobfile.csh filelist.txt.435 out_electron435.root>

Wed Mar 23 11:44:12: Submitted from host <rcas2077>, CWD </direct/phenix+data08/seto/run4/cabana/Out/Outewg47>, Output File <log435.log>, Requested Resources <linux>;

Thu Mar 24 05:40:33: S= tarted on <rcrs2125>, Execution Home </phenix= /u/seto>, Execution CWD </direct/phenix+data08/seto/run4/cabana/Out/Ou<= /span>

        =              tewg47>;

Thu Mar 24 12:17:08: Resource usage collected.

        =              The CPU time used is 279 seconds.

        =              IDLE_FACTOR(cputime<= /span>/runtime):   0.24

        =              MEM: 155 Mbytes;  SWAP: 830 Mbytes;  NTHREAD: 5

        =              PGID: 947;  PIDs: 947 948 949 1012 1013<= /o:p>

 

 

 SCHEDULING PARAMETERS:

        =    r15s   r1m  r15m=    ut      pg    i= o   ls    it    t= mp    s= wp    m= em

 loadSched   -    0.7    -     -       -     -    -     -     -      -      -

 loadStop    -    2.0    -     -       -     -    -     -     -      -      -

 

Here the SWAP<1GB. Its Ok.

To: phenix-off-l@bnl.gov

Subject: RE: subfigure

 

 

I guess most people don't usually program in TeX, but here's a little tidbit that should help a li= ttle bit.  Put this near the top of= your next LaTeX document:

 

\def\mean#1{\left<#1\right>}

 

and then, when you want to indicate a mean value in a formula, do it like this:

 

$\mean{x^2}$

 

(supposing you want to indi= cate the mean value of x squared)  = Now you'll get properly sized angle brackets that tightly surround both the "x" and the superscript "2&quo= t; instead of a too small "less than" sign and a too small "gre= ater than" sign too far away.  Looks better.  <= /span>Easier to read.

  It's the right thing to do.

 

Richard Seto

Physics Dept

University of California

Riverside CA, 92620

951-827-5623 Fax(4529) [new= ]

richard.seto@ucr.edu

 

> -----Original Message-----

> From: owner-phenix-off-l@bnl.gov

> [mailto:owner-phenix-off-l@bnl.gov] On Behalf Of David Morrison

> Sent: Tuesday, February 08, 2005 11:23 AM

> To: PHENIX-OFF-L@bnl.gov

> Subject: subfigure

>

> Hi all,

>

> OK, another LaTeX tip= .  I've seen people use lots of ways = to

> group multiple figures into one for a paper.  Lots of

> "mi= nipage" and so on.

> Here's a simpler way - just use the "subfigure" package

> that's part of a stand= ard LaTeX distribution.&= nbsp; Suppose you've

> got a collection of figures nobel1.eps, ..., nobel4.eps that

> you want to show as a group.  Do= something like this:

>

> \documentclass{articl= e}

> \usepackage{graphicx}

> \usepackage{subfigure= }

> \begin{document}

>

> \begin{figure}[htbp]<= /p>

>    \centering

>    \subfigure[Top left figure]{

>      \label{fig:tl}

>      \includegraphics[width=3D0.45\textwidth]{nobel1.eps}}<= /p>

>    \hspace{0.05\textwidth}

>    \subfigure[Top right figure]{

>      \label{fig:tr}

>      \includegraphics[width=3D0.45\textwidth]{nobel2.eps}}<= /p>

>    \vspace{0.05\textwidth}

>    \subfigure[Bottom left figure]{

>      \label{fig:bl}

>      \includegraphics[width=3D0.45\textwidth]{nobel3.eps}}<= /p>

>    \hspace{0.05\textwidth}

>    \subfigure[Bottom right figure]{

>      \label{fig:br}

>      \includegraphics[width=3D0.45\textwidth]{nobel4.eps}}<= /p>

>    \caption{Caption for t= he whole collection.}

>    \label{fig:all}

> \end{figure}

>

> \end{document}

>

> And they all end up nice and neat with individual captions

> and labels.

> Spiffy.

>

> Dave

> 

 

-----------------------

Cout doesn’t work pr= oblem

If you find your cout etc commands don’t work, you will need to include the line

using namespace std;

in your code