2012年9月22日星期六

[ZT] Install NS2 (ns-allinone-2.35) on Ubuntu 11.04 for beginners

Part I: Introduction
#======================

This installation guide is on Linux Ubuntu 11.04 (download from here), and  uses ns-allinone-2.35 source file for NS2. I assume that you have the skill to install Ubuntu, so I skip this process, and focus on the installation of NS2 (step-by-step with commands).

#========================
Part II: Installation
#========================

[Step 1]

Before install NS2, you have to install some essential softwares:

sudo apt-get install tcl8.5-dev tk8.5-dev
sudo apt-get install build-essential autoconf automake 
sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev

[Step 2]

Download NS2 source file  from from here.
Then you will get a file named “ns-allinone-2.35.tar.gz

[Step 3]

Unpack ns-allinone-2.35.tar.gz to your home directory. (/home/stan is my home directory, you SHOULD change it to your own!)

tar -zxvf ns-allinone-2.35.tar.gz -C /home/stan

[Step 4]

4.1) Modify the makefile (NOTICE: I use “vi” for an editor, you can use “gedit” instead)

vi /home/stan/ns-allinone-2.35/otcl-1.14/Makefile.in

4.2) Change CC = @CC@ to CC = @CC@ -V 4.5

(For changing this because the gcc complier in Ubuntu 11.04 is version 4.5, however NS2 only supports gcc-4.3 below. NOTICE the V is capital.)

[Step 5]

Install NS2:

cd /home/stan/ns-allinone-2.35
sudo ./install

[Step 6]

6.1) Modify  .bahrc

vi /home/stan/.bashrc

6.2) Go to the last line and add the scripts below:

export PATH=$PATH:/home/stan/ns-allinone-2.35/bin:/home/stan/ns-allinone-2.35/tcl8.5.10/unix:/home/stan/ns-allinone-2.35/tk8.5.10/unix
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/stan/ns-allinone-2.35/otcl-1.14:/home/stan/ns-allinone-2.35/lib
export TCL_LIBRARY=$TCL_LIBRARY:/home/stan/ns-allinone-2.35/tcl8.5.10/library 

6.3) Enable the path setting:

cd /home/stan  source .bashrc

#======================
# Part III: Verifying
#======================

which ns

If it shows /home/stan/ns-allinone-2.35/bin/ns,  it works!

For the original version of this article, please refer to http://stanjuly.wordpress.com/2011/12/22/install-ns2-ns-allinone-2-35-on-ubuntu-11-04-for-beginners/

2012年9月21日星期五

[ZT] Howto use the IEEEtran.cls Latex class file with Lyx on Ubuntu

Howto use the IEEEtran.cls Latex class file with Lyx on Ubuntu

With the help of several Ubuntu packages using the IEEE trans Latex class in the Lyx editor is very easy. To install use apt-get:

sudo apt-get install lyx texlive \
texlive-latex-extra \
texlive-math-extra \
texlive-science \
texlive-fonts-recommended \
texlive-publishers

And if you like confirm the required files are in the correct locations:

~/# find /usr/share/ | grep -i ieeetr
/usr/share/lyx/layouts/IEEEtran.layout
/usr/share/lyx/templates/IEEEtran.lyx
/usr/share/texmf-texlive/bibtex/bst/base/ieeetr.bst
...
/usr/share/texmf-texlive/tex/latex/IEEEtran/IEEEtran.cls

Then in the Lyx editor:
  1. Tools>Reconfigure
  2. Restart Lyx
  3. File>New from template
  4. choose the template /usr/local/share/lyx/templates/IEEEtran.lyx
Very easy once you know how! The template includes all the necessary magic ERT to get the IEEE class to work in Lyx.
 
For the original version, please refer to http://www.rrfx.net/2009/06/howto-use-ieeetrancls-latex-class-file.html

2012年9月20日星期四

[ZT] Using TeXstudio with SumatraPDF


Suma­traPDF is my favourite pdf reader and TeXs­tu­dio is my favourite LaTeX edi­tor. Here’s how to get them to work nicely together.
Go to Options/​Configure TeXs­tu­dio and click on “Com­mands”. Beside Pdf Viewer, untick “Inter­nal viewer” and add the fol­low­ing command:
"c:/Program Files/SumatraPDF/SumatraPDF.exe" -reuse-instance %.pdf
(If you have Suma­traPDF stored some­where other than the spec­i­fied paths, you will need to edit this accordingly.)
Then you need to tell Suma­traPDF how to jump to the cor­rect line in TeXs­tu­dio. From within Suma­traPDF, go to Settings/​Options and set the inverse search com­mand to
"C:\Program Files\TeXstudio\texstudio.exe" "%f" -line %l
Change the path to TeXs­tu­dio if necessary.
In order to go from the tex file to the cor­re­spond­ing loca­tion in the pdf, you can add a For­ward­Search com­mand within TeXs­tu­dio. Select “User” from the main menu, then “User com­mands” and “Edit User com­mands”. Then add a com­mand with the fol­low­ing definition:
dde://"C:/Program Files/SumatraPDF/SumatraPDF.exe":SUMATRA/control/
  [ForwardSearch("?am.pdf","?c:am.tex",@,0,0,1)]
(That should all be on one line with no space before [ForwardSearch. Again, edit the path for Suma­traPDF as nec­es­sary. Give the com­mand a name such as “For­ward­Search” and click “OK”. Now you should be able to jump to the cor­re­spond­ing part of the pdf file using “Alt-​​Shift-​​F1” (or what­ever key-​​combination is asso­ci­ated with your new command).
Being lazy, I pre­fer a sim­ple func­tion key. To map F2 to your new com­mand, select “Options/​Configure TeXs­tu­dio” and choose “Short­cuts”. Find your new com­mand under the User menu, dou­ble click to the right of it and select “F2” from the drop-​​down box. Pre­vi­ously F2 was mapped to LaTeX, but I never use LaTeX directly, so los­ing this func­tion is no problem.
Now you can dou­ble click on any part of the pdf from within Suma­traPDF and it should take you to the cor­re­spond­ing place in your tex file in TeXs­tu­dio. And then F2will take you back again.

For the original version of this article, please refer to  http://robjhyndman.com/researchtips/texstudio-sumatrapdf/

2012年3月6日星期二

MATLAB 图片参数设置

1. One column figure
position: width: 0.16; height: 0.34;
title font: 10
legend font: 9
mark size: 5
latex figure width: 7 cm

2. Three columns figure
position: width: 0.16; height: 0.34;
title font: 14
legend font: 12
axis font: 12
mark size: 6
line: 1.0
latex figure width: 18 cm