Filed under: By Language – English

Writing LaTeX in Word

LaTeX is good for two reasons: (1) great layout in publication quality; (2) separation of content and formatting (just like HTML), making it easy to reuse existing content. However, writing directly in LaTeX is not so good in that it is quite “anti-creativity”, especially when the essay is subject to constant change and development. Lyx is designed to resolve this issue, but unfortunately the editor is poor. Can we use MS-Word instead, as our daily writing environment, and still generate LaTeX script very easily on demand? The answer is yes. Let me show you this in three typical scenarios along with a list of useful resources and tools dealing with LaTeX.

  • Writing Papers

To write papers in MS-Word, but still generate LaTeX scripts, the key is a software converting MS-Word formats to LaTeX scripts. Among many software of this kind, the most recommended is Word2TeX. It is recommended for these reasons: (1) Most common elements for papers are supported. (2) the generated script is very clean and abstract, without unnecessary formatting in the original word file.

When a script is converted by Word2TeX, we can wrap it using the template files given by a conference/journal, just copy and paste the generated script into the body part of the template. Since the generated script is clean and abstract, usually the wrapped LaTeX script can be compiled immediately without any manual work.

Formulas in word files input using MathType can be converted into the LaTeX script automatically. And this part is the major reason for using MS-Word as the editor, as mathtype is so “creativity-supporting”. If you remember some keyboard-shortcuts, blind typing of formulas in MathType is possible and is a great experience. Another thing worth noting is that copy-and-paste from-and-to mathtype can be in LaTeX format.

Headings in word (input using Ctrl-Alt-1 etc.) can be converted into sections, chapters or so. Everything is customizable and automatic. Using headings itself is a recommended experience of using word.

Tables, figures, and even figures embedded in tables are automatic too without any manual work. In particular, if you paste vectorized figures into word, they are stored as vectorized. When the word file is being converted to LaTeX scripts, these figures are by default rastarized, which is not good. Yet there is an option in Word2TeX to convert images to eps, provided that you have a virtual postscript printer. To install a virtual postscript printer, the instructions mentioned in this page works if you have Microsoft Publisher installed. After that, everything is automatic again.

For theorems and proofs, there 2 things to do. (1) In word, create a new paragraph style. First pick a paragraph with “normal” style, then use “Save Selection as a new Quick Style” to save it as new style and name it “Theorem”, then modify the style format such that it is “italic”, it has a new “numbering list” format, starting with “Theorem ” and appended with numbering. By this step, the theorem in word really looks like a theorem. (2) When converting to LaTeX, in the configuration dialog of Word2Tex, add a new translation for paragraph style, translating “Theorem” style such that it prefix with “\begin{theorem}”, ends with “\end{theorem}”. Make sure that “suppress additional formatting” is chosen (this ignores numbering list and italic style in word, as they will be redefined in LaTeX anyway). In the generated LaTeX script, append this before document body:

\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}

Now theorem works. Proofs and so on can be done in the same way. Reference to theorems in word will also be properly translated.

Citation and bibliography is the most tricky part. According to the document of Word2TeX, if we use EndNote in word to deal with citations and bibliography, things should be automatic too. However, my experience is that this approach does not work at all (I don’t know why). The generated citation are just formatted texts, not being converted to citation switches like “\cite”. So my solution is to keep track of a personal “.bib” file (which can be reused every time when you write a paper). When writing papers in MS-Word, use waved underline formatting as citation, e.g., if there is an entry named “Geman84″ in my “.bib” file, then I can write  citation in MS-Word. After that in Word2TeX option page, we can choose to let waved underline be converted to “\cite”. In this way, the converted script will contain something like “\cite{Geman84}”.

There are a lot of other elements supported in Word2TeX.

  • Writing Presentations / Reports

Formal academic presentations are better written in LaTeX and compiled to ppts. There are a lot of LaTeX templates to do that, e.g., The LaTeX Beamer Class is a good choice. Similar to the above experience of writing papers, we can do this too when writing presentations. Simply write in word using “Bullets” or “Numbered Items”, then the generated script will contain “itemized” or “enumerate”. After that, what the beamer class require is that each ppt is begin with “\begin{frame}” and end with “\end{frame}”. There is no direct support for this in Word2TeX. But we can do tricky things again. Simply put something like “BeginFrame” and “EndFrame” in your word file, and when converted, find and replace them to “\begin{frame}” and “\end{frame}”. This does not cost too much work.

If you are a graduate student like me, you will surely write a lot of reports to present to your adviser. Writing reports is more like a daily creative process, so having a visual environment is even more important. All the experiences above for writing papers works here. In addition, my experience is that reports can be written in a way the same as presentations. It then provide a skeleton for presenting to our advisors. And when necessary, a formal presentation ppt can be produced on demand immediately.

  • Writing Blogs

If you have a wordpress blog like mine, then posting academic stuff is very easy. Suppose by the above experience, you write in word and have generated LaTeX scripts, then there are many plugins of wordpress turning LaTeX into blog posts. Among them, the most recommended is WP QuickLaTeX. The best thing of this plugin is that you can put a whole LaTeX page to the blog post editor, then add one tag to the top of the blog post, then everything is done, provided that the page does not contain too complicated stuff. Things like formulas, references to formulas, can all be taken care of automatically. To deal with citations, we can use a plugin called papercite. It is very simple but powerful. Simply put your personal “.bib” in your web directory, then citation and bibliography is very easy with this plugin.

See this post for an example.

  •  Useful LaTeX Resources and Tools

In addition to the above listed tools, some others help a lot in improving the experience of using LaTeX and Word together.

Detextify: This webpage recognizes drawing of symbols and translate them into LaTeX commands. It has two usages. The first is when you want to write in LaTeX a certain symbol, but don’t know it’s name in LaTeX. The second is when you are reading maths books and don’t know the meaning of a certain symbol. Knowing it’s LaTeX name helps you search over the Internet for its meaning. Note that when you are writing formulas with MathType, if you don’t know how to input a symbol, you can use this page and paste the LaTeX command into the MathType editor.

SmartDraw: Great tool for producing and maintenance of very fancy charts and figures efficiently. It is much better than visio in my opinion. It also produces EPS files. For example, if you are working on “probabilistic graphical models”, a subarea of machine learning, you will find this very useful.

Adobe Illustrator: Great tool for editing EPS figures directly. Good for final revision of papers, when EPS figures are already generated.

BibEdit: Great tool for maintaining BibTex files visually and efficiently. One can maintain a single BibTex file for all papers possibly used in future writing. Use the next tool for converting BibTex to MS Word reference.

BibUtil: Tool for converting among different bib formats.

CTeX: This is originally developed for the purpose of Chinese tex writing, but it turns out that it is also a very comprehensive all-in-one LaTeX package. Everything you need to write LaTeX are there, from editor, compiler, to previewer.

Yet the final tool is certainly Google, when you don’t know how to write LaTeX. I don’t think learn LaTeX thoroughly is a good idea. Template + Google is probably the best solution.

Leave a Comment March 24, 2012

Boolean Fourier Transform and the Laplacian

Boolean functions have a natural form of Fourier Transform [1], corresponding to eigenfunctions of the discrete Laplacian operator. Here is a short justification.

Boolean Function Space

Let F=\left\{ {f\vert f:\left\{ {0,1} \right\}^{n}\to \left\{ {-1,+1} \right\}} \right\} be the space of functions over n Boolean inputs. Each f\in F is a 2^{n}-dimensional vector. Attach to the 2^{n} vector space an inner product as follows,

(1)   \begin{equation*} \left\langle {f,g} \right\rangle =\frac{1}{2^{n}}\sum\limits_{x\in \left\{ {0,1} \right\}^{n}} {f\left( x \right)g\left( x \right)} ,\mbox{\thinspace \thinspace }\forall f,g\in F \end{equation*}

The induced norm is \left\| f \right\|=\sqrt {\left\langle {f,f} \right\rangle }. For Boolean functions f\in F, we have

(2)   \begin{equation*} \left\| f \right\|^{2}=\frac{1}{2^{n}}\sum\limits_{x\in \left\{ {0,1} \right\}^{n}} {f\left( x \right)^{2}} =1 \end{equation*}

Discrete Laplacian Operator

Define a graph of the domain of f\in Fas G=\left\langle {V,E}\right\rangle, where

(3)   \begin{equation*} \begin{array}{l} V=\left\{ {0,1} \right\}^{n} \\ E=\left\{ {\left\langle {i,j} \right\rangle \vert x_{i} ,x_{j} \in V,H\left( {x_{i} ,x_{j} } \right)=1} \right\} \\ \end{array} \end{equation*}

here H\left( {\cdot ,\cdot } \right) is the Hamming distance over binary vectors. Let the weight of each e\in E to be set as 1. Let d\left( {v_{i} ,v_{j} } \right) be defined as the Geodesic distance over G. Then the discrete Laplacian operator is defined as

(4)   \begin{equation*} \left( {\Delta f} \right)\left( v \right)=\sum\limits_{w:d\left( {w,v} \right)=1} {\left( {f\left( w \right)-f\left( v \right)} \right)} \end{equation*}

Fourier Basis as Eigenfunctions

For each s\in \left\{ {0,1} \right\}^{n}, define a function \phi_{s} :\left\{ {0,1} \right\}^{n}\to \left\{ {-1,1} \right\} as

(5)   \begin{equation*} \phi_{s} \left( x \right)=\left( {-1} \right)^{\sum\limits_{i=1}^n {x_{i} s_{i} } } \end{equation*}

For \forall a,b\in \left\{ {0,1} \right\}^{n},a\ne b, \exists j\in\left\{ {1,...,n} \right\}, such that a_{j} \ne b_{j}, we have

(6)   \begin{equation*} \small \begin{array}{l} \left\langle {\phi_{a} ,\phi_{b} } \right\rangle =\frac{1}{2^{n}}\sum\limits_{x\in \left\{ {0,1} \right\}^{n}} {\phi_{a} \left( x \right)\phi_{b} \left( x \right)} \\ =\frac{1}{2^{n}}\sum\limits_{x\in \left\{ {0,1} \right\}^{n}} {\left[ {\left( {-1} \right)^{\sum\limits_{i=1}^n {x_{i} a_{i} } }} \right]\left[ {\left( {-1} \right)^{\sum\limits_{i=1}^n {x_{i} b_{i} } }} \right]} \\ =\frac{1}{2^{n}}\sum\limits_{x\in \left\{ {0,1} \right\}^{n}} {\left( {-1} \right)^{x_{j} a_{j} +x_{j} b_{j} }\left[ {\left( {-1} \right)^{\sum\limits_{i\ne j} {x_{i} a_{i} } }} \right]\left[ {\left( {-1} \right)^{\sum\limits_{i\ne j} {x_{i} b_{i} } }} \right]} \\ =\frac{1}{2^{n}}\sum\limits_{x\in \left\{ {0,1} \right\}^{n},x_{j} =0} {\left( {+1} \right)\left[ {\left( {-1} \right)^{\sum\limits_{i\ne j} {x_{i} a_{i} } }} \right]\left[ {\left( {-1} \right)^{\sum\limits_{i\ne j} {x_{i} b_{i} } }} \right]} \\ +\frac{1}{2^{n}}\sum\limits_{x\in \left\{ {0,1} \right\}^{n},x_{j} =1} {\left( {-1} \right)\left[ {\left( {-1} \right)^{\sum\limits_{i\ne j} {x_{i} a_{i} } }} \right]\left[ {\left( {-1} \right)^{\sum\limits_{i\ne j} {x_{i} b_{i} } }} \right]} \\ =0 \\ \end{array} \end{equation*}

By (2), we have \left\langle {\phi_{a} ,\phi_{a} } \right\rangle =1. So the set C=\left\{ {\phi_{s} \vert s\in \left\{ {0,1} \right\}^{n}} \right\} is orthonormal, with cardinality 2^{n}, which is finite and the same as the dimensionality of F. So the set C forms an orthonormal basis of F

(7)   \begin{equation*} F=span\left( C \right) \end{equation*}

In addition, plug (5) into (4) we have

(8)   \begin{equation*} \begin{array}{l} \left( {\Delta \phi_{s} } \right)\left( v \right) \\ =\sum\limits_{w:d\left( {w,v} \right)=1} {\left( {\left( {-1} \right)^{\sum\limits_{i=1}^n {w_{i} s_{i} } }-\left( {-1} \right)^{\sum\limits_{i=1}^n {v_{i} s_{i} } }} \right)} \\ =\sum\limits_{j=1}^n {\left( {\left( {-1} \right)^{\left( {1+v_{j} } \right)s_{j} +\sum\limits_{i\ne j} {v_{i} s_{i} } }-\left( {-1} \right)^{v_{j} s_{j} +\sum\limits_{i\ne j} {v_{i} s_{i} } }} \right)} \\ =\sum\limits_{j=1}^n {\left( {\left( {-1} \right)^{\left( {1+v_{j} } \right)s_{j} }-\left( {-1} \right)^{v_{j} s_{j} }} \right)\left( {-1} \right)^{\sum\limits_{i\ne j} {v_{i} s_{i} } }} \\ =\sum\limits_{j=1}^n {\left( {\left( {-1} \right)^{s_{j} }+1} \right)\left( {-1} \right)^{\sum\limits_{i=1}^n {v_{i} s_{i} } }} \\ =\left( {\sum\limits_{j=1}^n {\left( {\left( {-1} \right)^{s_{j} }+1} \right)} } \right)\phi_{s} \left( v \right) \\ \end{array} \end{equation*}

So \phi_{s} is an eigenfunction of \Delta, with eigenvalue \lambda_{s} =\left( {\sum\limits_{j=1}^n {\left( {\left( {-1} \right)^{s_{j} }+1}\right)} } \right), which is two times the number of 0′s in s. So there are in total n+1 different eigenvalues of \Delta, each has C_{n}^{\lambda_{s} /2} corresponding eigenvectors.

Since the space \left\{ {0,1} \right\}^{n} is finite, there exists amatrix notation L\left( {v',v} \right) of the Laplacian operator such that

(9)   \begin{equation*} \left( {\Delta f} \right)\left( v \right)=\sum\limits_{v'\in \left\{ {0,1} \right\}^{n}} {L\left( {v',v} \right)f\left( v \right)} \end{equation*}

by representation theory, we have

(10)   \begin{equation*} L\left( {v',v} \right)=\sum\limits_{s\in \left\{ {0,1} \right\}^{n}} {\lambda_{s} \phi_{s} \left( v \right)\phi_{s} \left( {v'} \right)} \end{equation*}

Questions

  • What is the most fundamental mathematical structure to define Fourier Transform, a topological space, a metrical space or even a group?
  • Do they all correspond to certain kinds of eigenfunctions?

Reference

[1] [doi] N. Linial, Y. Mansour, and N. Nisan, “Constant depth circuits, Fourier transform, and learnability,” J. ACM, vol. 40, pp. 607-620, 1993.
[Bibtex]
@article{BooleanFourier,
 author = {Linial, Nathan and Mansour, Yishay and Nisan, Noam},
 title = {Constant depth circuits, Fourier transform, and learnability},
 journal = {J. ACM},
 volume = {40},
 issue = {3},
 month = {July},
 year = {1993},
 issn = {0004-5411},
 pages = {607--620},
 numpages = {14},
 url = {http://doi.acm.org/10.1145/174130.174138},
 doi = {http://doi.acm.org/10.1145/174130.174138},
 acmid = {174138},
 publisher = {ACM},
 address = {New York, NY, USA},
 keywords = {AC0 circuits, Boolean functions, approximation, complexity, harmonic analysis learning},
}

Leave a Comment December 26, 2011

The Chamber of Secrets has been Opened

But where is the entrance?

It’s time to take a break.

Science fiction movies prefer to depict aliens as insect-like, which are commonly ugly, cold blooded, uncivilized, without fear of death etc. However, at the same time, they usually have technologies we can’t even imagine of (e.g. district 9, cowboy and aliens, etc.). So does it mean that those species, somehow, at some point, evolved into a certain state, that unconsciously they know how to let P = NP (or approximately, but with guarantee), such that there is no need to have a highly civilized society to support researches which are unpredictable, and inventions can just be done on demand?

Leave a Comment December 11, 2011

Is There a Way We Can Be Immortal?

It seems rather too far away for the biological science area to discover the mechanism of natural death and find out a way to make existing people immortal. It will probably take more than 50 years. So I’m not hoping to have that applicable to me. Another possible approach is to first develop true AI and hopefully by using large scale AI, this science discovery process can be accelerated. However, based on my current knowledge of AI, the true AI, when developed, has limitation on its scale, which intrinsically, will not exceed the level of human intelligence to a non-trivial extent. What only we can do to improve the capability of AI is to improve the connectivity of AI systems to the external world, and the communications among individual AI systems. But after all, that is no more than a group of well-collaborated scientists.

However, there is still hope. We can do something like this: When we know truly what AI is and how intelligence works in our human brain, which is not that difficult, then we can develop a artificial brain(AB) that is functionally the same as the biological brain(BB), except that it is implemented by man made techniques, and will never die. A further step we need to go through is to develop a method to connect AB to BB, let the artificial neurons and biological neurons work together, exchange information freely. We make sure that at first, the portion of AB is 0%. Then the portion of AB goes up gradually by substituting neurons in BB one by one, using neurons in AB. Finally, we get a AB that never dies, and it is you. At any time when the substituting is happening, you are still alive and have your complete, unique personality with the hybrid brain. Once you are 100% in AB, then you can base your body on whatever you want, thus you never die. This is not that difficult compared to the biological approach, and is hopefully possible in the near future. I’m looking forward to that.

If you watched the Tron movie, this makes a reasonable explanation to the fact that people can change their physical forms to the digital correspondences, and still maintains their complete personalities continuously.

Leave a Comment April 26, 2011

The Secret

I believe this is the spirit of America. The law of attraction.

YouTube Preview Image

 

Leave a Comment April 17, 2011

Teaching Practice 3: Probabilistic Graphical Models

It’s so difficult to introduce Probabilistic Graphical Model in 8 minutes.

/video/SHAO_YuanglongLouis_Unit_III.flv

Leave a Comment February 19, 2011

Elevator

When I was waiting for the elevator today, I was thinking about given the condition that I had waited for a longer time, and a small constant $$\delta$$, the probability that the elevator arrives in $$\delta$$ time is getting higher. So I kept waiting. I was waiting with confidence. After a very long time I found that the elevator was broken.

2 Comments January 7, 2011

Living Chrismas Tree is Awesome

Again, I was shocked by Christian people in US. There are so many people volunteerily try their best to bring joy and happiness to people. The performance show tonight called “Living Chrismas Tree” is so carefully prepared and is awesome.

Living Chrismas Tree
This is the so called living Chrismas tree, singing all the way of the performance.

Jesus's Born
Not until this scene did I realize that this show is about the story of Jesus’s born. I saw a shrunk model of this scene in Phil’s home. So nice.

Camel
In the original story of Jesus’s born, there were a lot of animals presented. It’s said that Mary was riding a donkey when Jesus was about to born. And later, three kings came to help Mary by riding camels. So in today’s show, there are actually real donkeys, camels, horses and goats presented.

Leave a Comment December 4, 2010

Teaching Practice 2: Optimization

This is the third presentation in my English Speaking and Teaching class, which will in some sense determine whether I can upgrade to the most advanced English Speaking and Teaching class next quarter. Hope this works.

It’s difficult to explain such an abstract concept in 7 minutes. I used the example of cooking cup noodles with a microwave oven to introduce optimization.

/video/TL504Apr_Optimization.flv

Leave a Comment November 29, 2010

Chrismas Tree Decoration

Today I was invited to Philip and Elizabeth’s house to decorate their Chrismas tree together with their four kids and some Chinese friends.

Chrismas Tree

This is the tree we finally decorated. And with a magic glass, the stars are sparkling, which is very beautiful.

With Phil.

I prepared some stuff for them to decorate, including the crosses which Phil and Elizabeth end up hang up on their own. Also, I just notice that there is a little loli in the picture.

Leave a Comment November 29, 2010

Previous page


Categories

Archives

Recent Comments

Meta