Tuesday, November 15, 2011

Converting pdf to eps

Although pdf is better than eps format, some journals still insist the figure files in eps format. There are many possible option to convert the pdf files to eps files, although none of them is perfect.

Using Adobe Reader



  • Open the pdf file with adobe reader.
  • Print it to ps file. Make sure that the box "Choose paper source by paper size" is unchecked. 
  • Use the command ps2eps filename.ps to convert the ps file to eps file.
  • Open the eps file in a text editor and modify the BoundingBox parameters. The bounding box can be obtained by
    gs -dNOPAUSE -dBATCH -q -sDEVICE=bbox

    Using command line:
  • acroread -toPostScript input.pdf
  • ps2eps -f -l -B -s b0 -F input.ps
    or
  • ps2eps -f -B -s b0 -F input.ps


  • Using pdftops

    pdftops -eps filename.pdf
    will convert it to eps file. One can also use ps2eps to generate the bounding-box.

    Tuesday, October 25, 2011

    One liner - awk, gawk

    Print specific columns
    awk '{ print $5, $1, $2 }' fileName

    Print specific columns separated by : delimeter
    awk -F':' '{ print $5, $1, $2 }' fileName

    Count number of words in a line
    $awk '{print NF}' fileName


    Maximum in first column of a file
    $awk '$1 > max { max=$1;}; END { print max }' fileName 


    Minimum in third column of a file
    $awk 'NR==1 { min=$3 } $3 < min { min=$3;}; END { print min }' fileName


    Combining columns of two files
    $cat file1
    one two three
    one two three
    one two three



    $cat file2
    four five six
    four five six
    four five six



    $pr -m -t -s\ file1 file2 | gawk '{print $4,$5,$6,$1}'
    four five six
    four five six one
    four five six one



    Break a line into multiple lines
    $cat fileName
    1 2 3 4 5 6 7 8 9 10 11 12



    $awk -F' ' '{for(i=1;i<=NF;i++){printf("%s%s",$i,i%3?" ":"\n")}}' fileName
    1 2 3
    4 5 6
    7 8 9
    10 11 12


    Insert newline after every 2 lines
    $cat fileName
    FR 24
    AA 33
    EE 34
    EE 46
    BE 30
    AA 31
    DE 90
    AL 10

    $awk '!( NR % 3 ) {$0 = $0"\n"} 1' fileName
    FR 24
    AA 33

    EE 34
    EE 46

    BE 30
    AA 31

    DE 90
    AL 10

    Monday, September 12, 2011

    Inkscape Tips

    Make arrow head’s color match that of its body

    In Inkscape path/arrow starts are black by default. If you change the color of the body of the arrow, the head will remain black. The solution consists of using a plugin. To do so, select: 
    Effects->Modify Path->Color Markers to Match Stroke.

    Tuesday, August 30, 2011

    Change default application when opening files in ubuntu

    As always, after reading a certain post on the Ubuntu Forums, the answer was so easy and obvious. To change the default application for opening files of a specific type, do the following:
    1. Right-click on a file of the type you wish to set a default application to open it with
    2. Select Properties
    3. Select the Open With tab
    4. Select the application you want associated with that file-type
    5. Click OK

    Wednesday, July 20, 2011

    English Usage

    A very good website for Common Errors in English Usage.


    First / Firstly
    This is from Lynch's Guide to Grammar and Style:
    'The jury is still out on whether to use first or firstly, second or secondly, etc. Traditional usage had firstly, secondly, but this is too inconsistent for modern taste. Most guides prefer just plain old first, second, and so forth, without the -ly ending.'

    Affect and Effect
    The majority of the time we use affect with an a as a verb and effect with an e as a noun.

    Affect means "to influence" as in, "The arrows affected Ardvark," or "The rain affected Amy's hairdo". Effect has a lot of subtle meanings, but to me the meaning "a result" seems to be at the core of all the definitions. For example, "The effect was eye-popping," or "The rain had no effect on Amy's hairdo".

    Bought / Brought
    Bought relates to buying something. Brought relates to bringing something. For example, I bought a bottle of wine which had been brought over from France.

    Toward / Towards
    Both of them are correct. As the word acts as a preposition, not a noun, adding the “s” doesn’t make it plural. The only distinction between the two is that “toward” is used more often in American English, while “towards” is used more often in British English.

    Quotation Marks, Commas and Periods

    Universal American usage places commas and periods inside the quotation marks, regardless of logic.
    e.g., "Diane," she said, "put the book down and go outside for a little while."


    This rule applies even when the unit enclosed at the end of the sentence is just a single word rather than an actual quotation:

    e.g., To get to the next page, just press the little button marked "Enter."

    However, British are inclined to place commas and periods logically rather than conventionally, depending on whether the punctuation belongs to the quotation or to the sentence that contains the quotation.
    e.g,

    Have you read the assigned short story, "Flowering Judas"?
    No, but I did finally get around to reading last week's assignment,  "Where Are They Now?"




    Correct Forms
    • "I hope this helps" or "I hope this will help" instead of I hope this help.

    • Most of the time when one says “I could care less”, he/she mean to say “I could not care less”.