Showing posts with label TeX. Show all posts
Showing posts with label TeX. Show all posts

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}

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
C:\Program Files\WinEdt Team\WinEdt\Config\MikTeX\menu.dat

Windows Vista & Windows 7
C:\Program Files (x86)\WinEdt Team\WinEdt\Config\MikTeX\menu.dat

Then follow the post:

Run('mo.exe')

should be modified to

Run('mo_admin.exe')

The same with package manager. Replace

Run('mpm.exe')

with

Run('mpm_mfc_admin.exe')

And the update in 2.8 should be defined (in one line) as:

Run(|%$('TeX-Root');\miktex\bin\internal\copystart_admin.exe "%$('TeX-Root');\miktex\bin\internal\miktex-update_admin.exe"|);
In Windows Vista or Windows 7, if we want to refresh the TeX system, I found that running the following commands in the "Command Prompt" (Run as administrator) works better:

initexmf -u --admin
updmap -u --admin

That is running initexmf and updmap. in the administrative mode. These changes are going to be adopted in the next version of WinEdt. In the meantime, we just have to change these manually.


Tuesday, October 21, 2008

[TeX] Set a New Counter to Solve the Problem of Duplicate Identifier

Resetting counter can conflict with the hyperref package because hyperref will yield a warning message saying that there is a duplicate identifier. For example, if you have section 1.1, you will encounter this problem when you want to create a section 1.A for the appenix within a chapter.

\documentclass{book}
\usepackage{hypperref}
\begin{document}
\chapter{Introduction}
\section{What}
...
\renewcommand{\thesection}{\thechapter.\Alph{section}}
\setcounter{section}{0}
\section{Appendices}
\end{document}


If you don't use hypperref, this is not a problem. But if you do, the document will still be compiled correclty, but the hyperlink will not be pointing to the right target. So to solve this, you need to set a new counter.

\documentclass{book}
\usepackage{hypperref}
\begin{document}
\chapter{Introduction}
\section{What}
...
\newcounter{@appsec}
\setcounter{@appsec}{0}
\renewcommand{\thesection}{\thechapter.\Alph{@appsec}}
\stepcounter{@appsec}
\section{Appendices}
\end{document}


The step for \stepcounter makes the new counter works. Otherwise, it will show an blank space in the output.

Monday, October 06, 2008

Independent symbol in TeX

A friend of mine asked me how to type a independent symbol in Word using the equation editor. I was surprised that there is no such symbol in the equation editor. So I am proud of my self as the TeX user because I thought there must be such a symbol in TeX system. But I was wrong. You need to define it on your own. Luckily, Dr. Donald Knuth has done it. So here is the code:

\newcommand\independent{\protect\mathpalette{\protect\independenT}{\perp}}

\def\independenT#1#2{\mathrel{\rlap{$#1#2$}\mkern2mu{#1#2}}}


As usual, you can use $\independent$ to get the symbol.

For the Word user, here is the gif file for you to copy and paste it in.

Monday, August 06, 2007

cwTeX with LaTeX2html

利用 LaTeX2html 套件將 cwTeX 產生的中文 TeX 文件轉成 html 文件,需要在 preamble 及內文前加上指令,如此才能正確產生中文 html 文件。分別是在前言區載入 cwtex 套件,及在內文區取消cwTeX 字型。

# preamble
\documentclass{article}
\usepackage{cwtex}  

# mainbody
\begin{document}
\ctxfoff #取消cwTeX字型
中文文件
\end{document}

Monday, April 09, 2007

New appendix command in the article class

By default, the article class in LaTeX does not encourage users to write an appendix in an article. But users can still claim an appendix environment by typing:

\appendix

This will reset the counters for the section and subsection. However, (1) we have to manually type "Appendix" or "Appendices" for the section title; and (2) the counters for tables and figures still follow the numbering in the main text.

For the first point, there is the "appendix" package can deal with this.

# in the preamble
\usepackage{appendix}

# where you start your appendix
\appendix
\appendixpage

But this will give you an awkward large font for the section title for "Appendices." And the counter for tables and figures still following the main text counter.

The flexibility of TeX language allows us to write code to deal with aforementioned point 1 and point 2.

\renewcommand\appendix{\par
\setcounter{section}{0}%
\setcounter{subsection}{0}%
\setcounter{table}{0}
\setcounter{figure}{0}
\gdef\thetable{\Alph{table}}
\gdef\thefigure{\Alph{figure}}
\section*{Appendix}
\gdef\thesection{\Alph{section}}
\setcounter{section}{1}}


So now, put \appendix right before you write your appendix.

Saturday, February 17, 2007

Who should learn LaTeX?

I remembered that 2 years ago I decided to learn LaTeX. The motive is that LaTeX "seems" to generate better and prettier output. 2 years latter, some of my friends have asked me to teach them LaTex. I begin to wonder the question: who should learn LaTeX?

1. You must know how to use Microsoft Word very well.
When I learned LaTeX by myself, I got an opposite message from many manuals. LaTeX is powerful. LaTeX can do what MS Word cannot do. Although I am a LaTeX user now, I must say that there is nothing LaTeX can do that MS Word cannot. So if you are pursuing a "wonder" output and are a very skillful MS Word users, you should learn LaTeX! If you suck in MS Word, then forget about LaTeX, too.

2. You must be a careful writer.
I am disqualified as a careful writer as I always have typos here and there. MS Word has better embedded macro to point out your typos. Also, you must know how to type formally as LaTeX uses more strict rule for typesetting (e.g., `` as begin of quote instead of ").

3. You must be to some extent a computer geek.
What I mean is that LaTeXing is very similar to programming. A small bug in your typesetting command will yield a failed output. In this situation, you must be very patient to debug your code. But who can be patient on this. You must be a geek.

4. Your work is highly technical.
If your work contains equations, figures and tables, you should learn LaTeX. But of course, MS Word can do these things too. Just the output is ugly. More importantly, if figures in your work is the biggest selling point, learn LaTeX.

5. You want to create an illusion that your are one of the kind named above.
I recall a comment made by Professor Jeff Gill in 2006 ICPSR. He said that whenever he saw a work submitted for journal publishing done by LaTeX, he always has an image of a careful, devoted, know-his-work-well guy. So if you are not this kind, learn LaTeX. You may create a fake image. But in the long run, you will become a careful, devoted, know-his-work-well guy. Why? Learn LaTeX and you will know.

Friday, February 02, 2007

Combine several pdf files using Latex

pdfpages is a Tex package that can combine several pdf files using LaTex. Here is the usage:

\usepackage{pdfpages}
\begin{document}

\includepdf[pages=-]{1.pdf}
\includepdf[pages=-]{2.pdf}
\includepdf[pages=-]{3.pdf}
\end{document}

Monday, January 29, 2007

New command for keywords for abstract

There is no command and no enviroment for keywords of an abstract in LaTex unless some templates provide it. Here is a simple way to define a new command for keywords.


# code
\newcommand{\Keywords}[1]{\par\noindent
{\small{\em Keywords\/}: #1}}

# usage
\begin{abstract}
blah blah blah

\Keywords{blah.}
\end{abstract}

Saturday, September 30, 2006

Eliminate page numbering in the first page that has title information 消除有題目的首頁下方頁碼資訊

Q: How to eliminate page numbering in the first page that uses \maketitle?

\pagestyle{empty} cannot work properly if you don't put it in the right place. It should be placed right after \maketitle with no space and no line skip.

\begin{document}
\maketitle\thispagestyle{empty}
\end{document}

Monday, September 11, 2006

Place tables and figures in the back of a paper or a book 將圖表置於本文之後

Q. How to place tables and figures in the back of a paper or a book?
# in preamble
\usepackage[options]{endfloat}
options
nofiglist: no list of figures
notablist: no list of tables
nolists: neither list
figlist: list of figures
tablist: list of tables
lists: list of tables and figures
nofighead: no "Figures" section header
notabhead: no "Tables" section header
noheads: head neither of the headers
fighead: "Figures" section header
tabhead: "tables" section header
heads: Both section headers
markers: Place markers in the text
nomarkers: no markers in text
tablesfirst: Put tables before figures
figuresfirst: Put figures before tables



# To have multiple figure per pages in the end, use the following code:
\renewcommand{\efloatseparator}{\mbox{}}

Monday, September 04, 2006

在cwTeX中使用全形標點符號

Q: 如何在cwTeX中使用全形標點符號?

因為cwTeX不使用全形標點符號,所以要做以下修改。在preamble中加入以下的code。然後使用取代功能將全形標點符號改成以下定義。例如將。改成\pe。配合中文化的引用格式(capsr.bst),要在前言加入% bib use以後的code使用。

\def\pe{\nolinebreak[4]\hspace{.3em}\raise.7ex\hbox{。}\hspace{.3em}}
\def\ca{\nolinebreak[4]\hspace{.3em}\raise.8ex\hbox{,}\hspace{.3em}}
\def\pa{\nolinebreak[4]\hspace{.3em}\raise.8ex\hbox{、}\hspace{.3em}}
\def\ccolon{\nolinebreak[4]\hspace{0.3em}\raise.3ex\hbox{:}\hspace{.3em}}
\def\ql{\nolinebreak[4]\hspace{.3em}\hbox{「}\hspace{.3em}}
\def\qr{\nolinebreak[4]\hspace{.3em}\hbox{」}\hspace{.3em}}
% bib use
\def\cperiod{\nolinebreak[4]\hspace{.3em}\raise.7ex\hbox{。}\hspace{.3em}}
\def\crightquote{\nolinebreak[4]\hspace{0.1em}\hbox{〉}~\raise.8ex\hbox{,}\hspace{.3em}}
\def\cleftquote{\nolinebreak[4]\hbox{〈}\hspace{0.1em}}
\def\ccomma{\nolinebreak[4]\hspace{.3em}\raise.8ex\hbox{,}\hspace{.3em}}
\def\ccolon{\nolinebreak[4]\hspace{.3em}\raise.3ex\hbox{:}\hspace{.3em}}



Monday, May 08, 2006

\marginpar shows up in the wrong side in the two side document 邊界註解在二面印刷中產生在錯誤的一邊

Q. How to fix the bug of margin notes showing up in the wrong side?

This is a known issue of \marginpar. One way to solve it is to call mparhack package to fix it. But the author withdraws the claim that this can fix the problem So instead of using \marginpar, use \marn instead. It will fix the problem.

# preamble
\usepackage{marn}
# usage
\marn{this is a margin note}

The marn style file is not included in most of the tex system. You can download it from here. If the link is dead, you can also download the file from here.

Sunday, April 09, 2006

Customize symbol in \eumerate 自訂條列環境符號

Q. How to customize symbol in \enumerate environment

# in preamble
\usepackage{enumerate}

# in main text
\begin{enumerate}[--]
\item first list
\item second list
\end{enumerate}

Note: cannot work with \enumitem.

Customize equation name 自訂方程式名稱

Q. How to cutomize equation name?

Use the style file eqname.sty

# preamble
\usepackage{eqname}

###################################
LaTeX document style option eqname.sty
Gerd Neugebauer 4/92
gerd@intellektik.informatik.th-darmstadt.de

This style option allows named equations as follows

1 + 1 = 2 (17)
1 + 2 = 3 (bingo)
1 + 3 = 4 (18)

This can be produced by

\begin{eqnarray}
1+1=2 \label{e1}\1+2=3 \eqname{bingo}\label{e2}\1+3=4 \label{e3}
\end{eqnarray}



Note: The \label has to go after the \eqname command.


Bugs & Problems:
This style option does not work with leqno.sty

Saturday, March 25, 2006

Numbering in equation, table, figure 公式、表格、圖表編號方式

Q. How change the depth of numbering in equation, table, and figure?

#\numberwithin{#type}{#section depth}
\numberwithin{equation}{section}
\numberwithin{table}{section}
\numberwithin{figure}{section}

Landscape mode 橫式版面

Q. How to switch to landscape mode?

\begin{landscape}
text....text...
\end{landscape}

Friday, March 24, 2006

Create hyper link in paper 在文章中使用超連結

Q. How to create hyper link in paper?
# in preamble
\usepackage{xcolor} # use more color
\usepackage[colorlinks=true, urlcolor={violet}, citecolor={blue}, linkcolor={red}]{hyperref}

Wednesday, March 22, 2006

Changing numbering style in subfigure 更改subfigure編號方式

Q. How to change numbering style in subfigure?

1. in subfigure show 12.1:, 12.2:, in ref show 12.1, 12.2.
#put the following code in preamble.

\renewcommand{\thesubfigure}{\roman{subfigure}}
\makeatletter
\renewcommand{\@thesubfigure}{(\thesubfigure)\space}
\renewcommand{\p@subfigure}{\thefigure}
\makeatother

2. in subfigure show (i), (ii), in ref show 12i, 12ii.
#put the following code in preamble.

\renewcommand{\thesubfigure} {\thefigure.\arabic{subfigure}}
\makeatletter
\renewcommand{\@thesubfigure}{\thesubfigure:\space}
\renewcommand{\p@subfigure}{}
\makeatother

Bold font in Math 數學式中的粗體字型

Q. How to create bold font in math characters?


#in preamble

\usepackage{bm}

#in context

\bm{x}