Thursday, June 24, 2010

CMYK and RGB color code in TeX

I found that control coloring in TeX is not an easy task.  Sometimes, you want your font to be colored as brown.  But brown is not explicitly defined in the color package.  I found a web page that provides detailed color pallet with the color name and the CMYK and RGB setting.

Here is the link to the webpage.

http://www.december.com/html/spec/colorcodes.html

So you can look up the percent code of CMYK or RGB in this webpage and define the color in TeX as the followings:

1. Call the package color

\usepackage{color}


2. Define the RGB color

\definecolor{brown}{RGB}{128,42,42}


or

\definecolor{brown}{cmyk}{0,0.67,0.67,0.50}

Sunday, June 06, 2010

General steps to compile JAGS in a Linux based OS system and install rjags in R

I have an entry here about how to install JAGS and rjags in Fedora.  However, I have exchanged emails with Robert Dorazio and Dr. Martyn Plummer.  Here are the easier steps to compile JAGS and install rjags in R.

1. After you extract the source code of JAGS, go to the folder where the JAGS makefile is using a terminal.
cd JAGS-2.1.0

2. In a terminal, type the following
sudo ./configure --prefix=/usr
sudo make
sudo make install


3. The step 2 will help your system to identify where the JAGS is.  So in R, you can simply install rjags as:
install.package("rjags")

Of course, once you can install rjags successfully in R, you can install our R2jags package as well:
install.package("R2jags")

JAGS, rjags, and coda packages for Fedora

Christopher has the RPMs (for Fedora users) for JAGS, coda, and rjags on his blog. The specific blog entry is here:

If you have trouble installing JAGS or rjags in Fedora, this is going to simplify the installation process.

Wednesday, January 13, 2010

TeXing Chinese, Japanese, Korean (UTF-8) Documents using xeLateX

I have been converted myself from a Word user to a TeX user for over 5 years.  Since the release of xeTeX (a new TeX package that can use system fonts to type Non-Egnlish [UTF-8] documents), I have been using it whenever I wanted to type a Chinese document.  However, it is not easy.  The biggest hurdle is that you have to write some commands in the preamble and have special packaged fonts to be able to switch between Chinese and English if you want to use beautiful TeX Fonts in your documents.

Here is the font package provided by Edward Lee (LGJ).  The manual of the way to use it is here.

Nonetheless, last year, Sun Wenchang released a TeX package XeCJK . It makes TeXing with UTF-8 documents easier.  You can specify the use of Chinese fonts in the document without changing the default English font (Latin Modern).

Here is the template of how things get done:

\documentclass{article}
\usepackage{fontspec} % package for setting fonts
\usepackage{xeCJK}    % package for setting Chinese fonts
\defaultfontfeatures{Mapping=tex-text}
% Chinese font main settings
\setCJKmainfont[BoldFont={Microsoft JhengHei},ItalicFont={DFKai-SB}]{PMingLiU}
\setCJKsansfont{cwTeXYen}
\setCJKmonofont{Adobe Fangsong Std}  % or cwTeXFangSongTT
% linebreak setting for Chinese
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt

\setCJKfamilyfont{zhhei}{Microsoft JhengHei} % or cwTeXHeiBold
\setCJKfamilyfont{zhkai}{DFKai-SB} % or cwTeXKaiItalic
\setCJKfamilyfont{zhfs}{Adobe Fangsong Std} % or cwTeXFangSongTT
\setCJKfamilyfont{zhyou}{cwTeXYen}
\newcommand*{\song}{\CJKfamily{zhsong}}
\newcommand*{\fs}{\CJKfamily{zhfs}}
\newcommand*{\hei}{\CJKfamily{zhhei}}
\newcommand*{\kai}{\CJKfamily{zhkai}}
\newcommand*{\yen}{\CJKfamily{zhyou}}
\title{\it 文件題目}
\author{作者}
\date{\today}
\begin{document}
\maketitle
This is a Chinese document. 這是一份中文文件。\textbf{This is a Chinese document. 這是一份中文文件。}\textit{This is a Chinese document. 這是一份中文文件。}{\song This is a Chinese document. 這是一份中文文件。}{\fs This is a Chinese document. 這是一份中文文件。}{\hei This is a Chinese document. 這是一份中文文件。}{\kai This is a Chinese document. 這是一份中文文件。}{\yen This is a Chinese document. 這是一份中文文件。}
\end{document}


Still, you might need some effort to find out the fontname in your system in order to make it working.  For instance, you can use 標楷體 as the Kai font in the template.  Or to be more general, use DFKai-SB, which is a default English name for this font.  If you download the fonts provided by LGJ, the fontnames are commented in the template.

There is one the last thing to make things working.  You have to pick a TeX editor that can edit UTF-8 documents.  I found TeXmaker or Texwork are two good ones.

Monday, November 30, 2009

An OpenSSH software for Windows 7 / Vista

Here is an OpenSSH software I personally found useful and working well under Windows 7 / Vista.  It is copSSH.

Besides it is free and open source, it is still actively maintained.  It works well with the UAC (user account control setting) of Windows 7 / Vista.  And it does not clash with Rtools.exe.

Saturday, November 14, 2009

MikTeX 2.8 and WinEdt 5.6

The current WinEdt needs some adjustment to work with MikTeX 2.8. The developer of WinEdt has a post here to show how to do this. I tried to follow his instruction. But it still took me some times to figure out which file I need to make the change. Basically, we need to alter the "menu.dat." The file is located in:

Windows XP

Windows Vista & Windows 7

Run('mo.exe')

should be modified to

The same with package manager. Replace

Run('mpm.exe')

with

Run(|%$('TeX-Root');\miktex\bin\internal\copystart_admin.exe "%$('TeX-Root');\miktex\bin\internal\miktex-update_admin.exe"|);