显示标签为“LaTeX”的博文。显示所有博文
显示标签为“LaTeX”的博文。显示所有博文

2013年3月31日星期日

Several Tips for Publishing Images from Matlab: PDF to Word, Font Size in Ubuntu etc.

Matlab provides some great convenience in creating high quality figures. However, esp. when you try to integrate these figures into your Word version of the paper, quite a few tweaks are needed.

1. Create, crop and insert high quality PDF images into word.

Matlab can create PDF or EPS figure quite easily by the print command, and you can even use LaTeX to combine multiple figures into one when you have to (subplot in Matlab create a very large margin between figures). However, one problem is to crop off the margins around the PDF. "pdfcrop" is a command line program in Ubuntu, but apparently it can not remove the margin on the bottom of the PDF. I found a nice Java program:

http://www.pdfscissors.com/

This can do the job quite nicely.

Then, before inserting PDF into word, keep in mind that there is no way to include such vector image into M$ Word documents. We have to convert it into high-quality TIFF image. There are quite a few options for this, just make sure to create TIFF image with 600 dpi. Just to be safe.

2. Change font size of Matlab figure in Ubuntu and save it into EPS.

This is a weird problem I had for a long time. Every time I tried to set the font size of Matlab figure in Ubuntu, it does not work. The same code works fine in Windows 7. The problem was that a font package is missing for Ubuntu. Just type:


sudo apt-get install xfonts-75dpi

Log out and log in, then it all works fine. Also, before save the figure as EPS, make sure to include:

set(gcf, 'PaperPositionMode', 'auto');

2012年10月11日星期四

Make LaTeX floats behave better

LaTeX floating objects can easily give me headaches. Today I saw this link:

http://mintaka.sdsu.edu/GF/bibliog/latex/floats.html

It provides a set of really neat commands to put in the beginning of your document, and all of a sudden the floats behave so nicely now :-)


% Alter some LaTeX defaults for better treatment of figures:
    % See p.105 of "TeX Unbound" for suggested values.
    % See pp. 199-200 of Lamport's "LaTeX" book for details.
    %   General parameters, for ALL pages:
    \renewcommand{\topfraction}{0.9} % max fraction of floats at top
    \renewcommand{\bottomfraction}{0.8} % max fraction of floats at bottom
    %   Parameters for TEXT pages (not float pages):
    \setcounter{topnumber}{2}
    \setcounter{bottomnumber}{2}
    \setcounter{totalnumber}{4}     % 2 may work better
    \setcounter{dbltopnumber}{2}    % for 2-column pages
    \renewcommand{\dbltopfraction}{0.9} % fit big float above 2-col. text
    \renewcommand{\textfraction}{0.07} % allow minimal text w. figs
    %   Parameters for FLOAT pages (not text pages):
    \renewcommand{\floatpagefraction}{0.7} % require fuller float pages
 % N.B.: floatpagefraction MUST be less than topfraction !!
    \renewcommand{\dblfloatpagefraction}{0.7} % require fuller float pages

 % remember to use [htp] or [htpb] for placement

2012年10月5日星期五

LaTeX centering a table that is larger than text width

Had this problem today with my thesis proposal, and luckily the solution is not hard to find:
http://mathandprogramming.blogspot.com/2011/07/latex-centering-table-larger-than.html

You basically need to use a package called chngpage and add an environment surrounding the table:

% allows for temporary adjustment of side margins
\usepackage{chngpage}

\begin{table}
    \begin{adjustwidth}{-.5in}{-.5in}  
        \begin{center}
        \begin{tabular}{|c|}
           % really wide table here
        \end{tabular} 
        \caption{This way the caption will also be the same width as the table, wider than the other text. }
        \label{myTable}
        \end{center}
    \end{adjustwidth}
\end{table}

2012年5月15日星期二

Some useful functions for subplot in Matlab

So there are two things that the subplot function in Matlab can not do.

1. Generate an "overall" title on the top of all sub-figures.
2. Make the sub-figures as compact as possible (usually very large margins will be made).

Normally, what we can do is save each sub-figure as eps or pdf, and use LaTeX to organize them. This works well and I highly recommend this way when you are preparing publication ready figures, but there are times that you just want to generate some report quickly and nicely.

So I found this two nice functions in Matlab file exchange:
1. mtit. This one will place a title automatically for you on top of everything.
2. subaxis. This one does roughly the same thing as "subplot", but with options that enables you to remove margins.

2012年5月9日星期三

Solving the LaTeX error: "Too many unprocessed floats"

Yesterday I generated a LaTeX document using Matlab script. This document have about 50 tables, with even table embedded with 30 images. So LaTeX thought that it I can't handle this much floating objects.

I searched around on the internet and found the best solution for me is to add
\clearpage
after every table. This command will force LaTeX to dump all the cached floating objects till here. So basically it will print one table per page, which is fine in my case.

2012年2月8日星期三

Paper writing notes learned from Dr Thompson

Today I received another thorough editing from Dr Paul Thompson. I found some pattern that I think I should keep in mind for later.

1. In .bib files, when you need some character to be in Cap in the generated PDF, e.g. "fMRI" somewhere in the title, do the following in the .bib file: "f{MRI}".

2. The use of tenses! Make them consistent!

3. Dr Thompson seems to have an issue with "utilize", he changed all of them to "use"... I thought "utilize" sounds cooler :-(

4. "More details can be found..." is always changed into "More details may be found..."

5. Things like "achieves the best performance..." is always changed into "perform the best...". I think he don't like to convert verbs into nouns...

6. Do not say "our method can benefit../will be able to...". Say it with proud: "our method benefits.../will..."

7. He generally likes the sentence to be concise. E.g., "if utilizing all these additional information will be beneficial for classification..." is changed to: "if this additional information can help classification..."

8. "The results are summarized in...." is always changed into "Results are summarized in...", not sure why though...

9. He does not like "As we can observe from the Table..."; these are changed to "As we see in Table...". But Sherlock always tells us to observe T__T

2009年7月17日星期五

Convert Excel Chart to EPS without any loss of fanciness

OK, I should confess that this web-log contains a whole bunch of stuff related to Microsoft and Non-free software... Well, I am in ASU now, as long as I can use all of them free of charge legally, who cares...

First of all, I checked a lot of articles on the web, regarding how to do this. But most of them just save the chart to as a image file, and convert it into EPS. WTH is that? All the nice properties of eps that you won't loss any resolution when inserted into your LaTeX file, the whole purpose of vector graphics!

OK. You should have Adobe Professional installed on your computer.

Now the steps looks kinda weird, but it is true...

Select the chart in Excel, paste it into a random Power Point file. Then select it in PPTX, paste it into a Visio file. Then, in Visio, set the page to fit the chart, and print it as PDF. Open PDF in Adobe professional, save it as eps. Vola...

2009年5月19日星期二

Emacs + LaTeX, even easier

OK.

sudo apt-get install auctex

This thing can give you a whole new style of syntax highlighting dedicated to make your LaTeX life easier.

Changing fonts
C-c C-f C-i \textit{} - Italics
C-c C-f C-b \textbf{} - Bold face (In math mode, this will invoke the \mathbf{} font)
C-c C-f C-e \emph{} - Emphasized
C-c C-f C-s \textsl{} - Slanted
C-c C-f C-r \textrm{} - Roman
C-c C-f C-f \textsf{} - Serif
C-c C-f C-t \texttt{} - Typewriter
C-c C-f C-c \textsc{} - Small Caps
If you want to change font attributes of existing text, mark it as a region, and then invoke the commands.

Sections, Environments, formatting, etc
C-c C-s \section{} \chapter{} \subsection{} - Sections
C-c C-e \begin{} & \end{} - Environment
C-c ] - Close Environment
C-c C-m - Macros
C-c RET(Enter) - Macros
C-c C-j() - Newline with \item inside itemize and so
C-c { - Insert balanced braces
M-q - Fill and indent current paragraph (format it)
C-c C-q C-e - Format current environment

Commenting
C-c ; - Comment current region
C-c : - Uncomment current region
C-c % - Comment current paragraph

Running and viewing
C-c C-c - Run LaTeX on text
C-c C-c after compling - Default View
C-c ` - Go to the next error
C-c C-t C-p - Toggles between DVI and PDF output

Queried search and replace
To do a queried search and replace (with a prompt for replacing each occurrence of a text string), press M-% . You will then be prompted for your search and replace strings. Emacs will find and display each occurrence of the search string and ask you for further instructions. You can respond with any of the following options:
Spacebar Replace text and find the next occurrence
Del Leave text as is and find the next occurrence
. (period) Replace text, then stop looking for occurrences
! (exclamation point) Replace all occurrences without asking
^ (caret) Return the cursor to previously replaced text

If you type any other character, Emacs will stop looking for occurrences and execute the character as a command. To restart the queried search and replace, type:
C-x M- M-RET

2008年9月13日星期六

LaTeX Highlighting in Emacs

I choose emacs as my major LaTeX editor for two simple reasons. One is the highlighting (especially when you input the title for a section), another is the simple line wrap (M-q).

But suddenly, after I got my MacBook Pro and set up Ubuntu on it, Emacs do not have highlighting for LaTeX any more...

God!! Kile, winefish are all good ones, but without line wrap!!! And much less keyboard short cuts!! I want my Emacs back!

I surf and surf, and found that emacs can be customized by simply editing the ~/.emacs file! I did it even easier -- download someone else's...

http://cermics.enpc.fr/~lelong/Emacs/index.html

2008年6月3日星期二

Kile中不能拼写检查和预览的问题

点击拼写检查,会提示I(A)Spell不能打开。
sudo apt-get install kcontrol ispell
就可以了

点击预览时,会提示有个什么东西没有装,装上这个就行了:
sudo apt-get install kghostview
而且还可以选中一段专门预览,非常方便:-)

ubuntu 7.10下搞定Latex + CJK

以前一直被ZDD告诫,说CJK很难配的...

就一直没敢配。那天突然心血来潮,试了一下,发现其实非常简单...



1. 安装texlive

一般安装的是:

sudo apt-get install texlive texlive-math-extra texlive-latex-base texlive-lat

ex-extra texlive-latex-recommended texlive-pictures texlive-science texlive-bi

btex-extra texlive-common latex-beamer



其实如果空间够,直接一个

sudo apt-get install texlive-full latex-beamer

我试了一下,需要1GB以上的空间,我家是网通的网络,所以...

建议自己去新利得上搜一下,除了doc之类的都装一下也没什么...



编辑器可以用winefish,很小巧,功能也很多。



2 安装cjk

sudo apt-get install latex-cjk-chinese ttf-arphic-* hbf-*



3 安装字体

从这里下载字体:

ftp://cle.linux.org.tw/pub2/tex/cjk/fonts/nsungt1

下载解压后,执行那个install.sh的脚本(不要用root执行)

P.S. 那个FTP上还有不少好东西。比如这里就还有个楷体字体:

ftp://cle.linux.org.tw/pub2/tex/cjk/fonts/nkait1



4 测试

用这段代码试试:

\documentclass{article}
\usepackage{CJK}
\begin{CJK}{UTF8}{nsung}
\begin{document}
\Huge Echo 万岁!
\end{document}

\end{CJK}



和网上很多代码不同的是:这里用的是UTF8编码(ubuntu默认的编码),

字体为nsung。

当然,如果安装了前面说的楷体和ttf-arphic*,也可以把nsung改成:

nkai

gbsn

gkai



我都试过,这四种字体都可以用,而且直接使用支持utf8的编辑器就可以,emacs,kile,

winefish之类的都回来了......偶活活活......



Long live Ubuntu!