Showing posts with label Latex. Show all posts
Showing posts with label Latex. Show all posts

Tuesday, March 13, 2018

LaTeX Series: Local TeX Tree

1. Destination texmf-local: your local TeX tree

The first step is to determine in what directory the new font will live. You can't choose just any directory, it has to be part of the TeX hierarchy. The best choice is your “local texmf” tree, which you can determine as follows:
MiKTeX
Navigate through the MiKTeX program:
Start > Programs > MiKTeX > Maintenance > Roots
(or MiKTeX Settings, in older versions). Some paths shown there have a Description such as InstallUserConfig, or UserData. A tree labeledUserConfig (but not any of the others) is an acceptable target for your new fonts, if you have no permission to create a new tree. However, it is better to use a tree without a description, as follows:You can create a new local tree by clicking on Add. The folder must not contain files at its root level or MiKTeX will reject it. Files in the folder must be in subfolders similar to the subfolders in the Install root. (MiKTeX info.)
TeX Live and MacTeX
From a system terminal (aka command prompt, shell window) enter the command kpsewhich --var-value TEXMFLOCAL to see the directory name. The default on Unix is /usr/local/texlive/texmf-local.
If you are not using one of the above TeX distributions, you'll need to consult other documentation.

2. Manual Package Installation

2.1 MikTex

If you want to install your own .sty files, then you should copy the files into the directory tex/latex/mystuff relative to a new TEXMF root directory.
Example:
  1. Create a new TEXMF root: mkdir ~/mytexmf
  2. Create a sub directory: mkdir -p ~/mytexmf/tex/latex/mystuff
  3. Copy your .cls and/or .sty files to ~/mytexmf/tex/latex/mystuff
  4. Register the TEXMF root directory ~/mytexmf
The last step can be carried out in MiKTeX Console.

2.2 TeX Live and MacTeX

The following are the steps that you should follow to install a new LaTeX package into your own home directory.
  1. Download the package file(s) from wherever they are available. Most packages are available from CTAN; enter appropriate keywords in the search fields to find the files.
  2. Packages may be distributed in different ways. Many packages on CTAN, for instance, come with a .dtx file and a .ins file. If the package you are installing comes with these files, you will have to process them with latex to create the actual files that make up the package. That is, type
    latex filename.dtx and/or latex filename.ins
    to unpackage the various .sty and other files in the package.
  3. Create a directory ~Library/texmf in your home directory, if there is not one there already.
  4. Install the various package files into subdirectories of texmf as follows:
    • All .bst and .bib files into texmf/bibtex (or subdirectories)
    • All font-related files into texmf/fonts (or subdirectories)
    • All documentation files into texmf/docs
    • All other files (.sty.cls.tex, etc.) should go into texmf/tex.
Alternatively, you could put all of the .sty etc. files into the same directory as the document you are editing. However, if you end up wanting to use them again later, you will have to copy them into the new directory as well, so in the long term it is probably better to put them into ~/texmf.

Source: [1, 2, 3, 4]

Thursday, January 22, 2015

LaTeX Series: How to Convert From LaTeX to MS Word

There will be times when you have to use MS Word format of your LaTeX documents. As far as I'm concern, there is no perfect software or workaround currently available to produce 100% LaTeX-MS Word compatible conversion.

However, there are currently a few methods with some pro and cons here and there.

My choice for now is TeX4ht.

Here's explanation of the command needed for the conversion [link] and some workaround for the known problems [link 1, link 2, link 3]

Tuesday, July 8, 2014

LaTeX Series: Embed Font & Generating Correct Margin

For IEEE submission, the font have to be embedded into the file. However, usually latex will not embed fonts such as Times-Italic, Times-Roman, Times-BoldItalic, Times-Bold, Helvetica and Courier.

It can be easily fixed using Adobe pdf printer, however you need to have Adobe Pro. As an alternative way, you could use terminal or command window to generate the desired pdf by using commands below.

Command Window
dvilatex file.tex
bibtex file
latex file.tex
latex file.tex
dvips -Ppdf -G0 -tletter file.dvi 
ps2pdf -dCompatibilityLevel#1.4 -dPDFSETTINGS#/prepress file.ps file.pdf

Terminal
ps2pdf -dCompatibilityLevel=1.4 -dPDFSETTINGS#/prepress file.ps file.pdf
[Source]


The command:

dvips -Ppdf -G0 -tletter file.dvi

will generate a letter size output. You can change the desired size by the -t option such as a4 to generate A4 size output.

Tuesday, April 22, 2014

How To Convert EPS to PNG?

Sometimes, when writing scientific journal, the publisher requires you to submit figures in MS WORD file. For me, it would be troublesome as I always save my figure in EPS format to be used together with LaTeX.

Luckily, INKSCAPE can save you from creating the figure from scratch. Follow these steps for EPS to PNG conversion:

  1. Open Inkscape
  2. Click File -> Import
  3. Select .eps file
  4. Click File -> Export Bitmap..
  5. Select Drawing 
  6. Change Bitmap size to 300 dpi or any desired value
  7. Click Export






Monday, February 24, 2014

LaTeX Series: XeLaTeX

Knowledge of the day:

You can use XeLaTeX to use system fonts instead of limited to fonts provided by TeX.

Try it yourself using the following codes, and compile with XeLaTeX

\documentclass[11pt]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{fontspec}
\setmainfont{Arial Narrow}
\begin{document}
\blindtext
\end{document}

Happy "XeLaTeX"ing

Tuesday, February 18, 2014

LaTex Series: Tex @Manjaro

It is a remarkable experience to use Tex with my xfce-Manjaro. It took me sometime to work out the configuration before I could generate my first IEEE paper with Tex in unix environment.

What you need are:
  • Tex Live
  • Texstudio

To install Tex Live, I use:

yaourt -S gedit-latex

Then, you can run your first Tex doc with either

latex sample.tex

or

pdflatex sample.tex

It is difficult, however, to write a Tex document without auto-completion function which require deep understanding on each syntax. Texstudio (my favourite so far) did help me a lot. Easy to understand and simple to use. Installation is simple:

yaourt -S texstudio

You need to modify the command for latex, pdflatex and any other stuff for compilation. To configure latex and pdflatex, the steps are detailed below:

  • Option -> Configure TeXstudio -> Commands
  • Click open folder icon on latex and pdflatex -> Select latex and pdflatex in "bin/" folder

Now you can run your TeXstudio, write your first TeX conference/journal paper.


Happy "TeXing"







Monday, February 17, 2014

LaTex Series: Equation

Equation Editor


Writing long equation in latex is challenging for beginner. Luckily TeXaide from MathType (obsolete) is (was) around (ask Dr. Google).

This simple program acts like Equation Editor in MS Word (Equation editor 3.0) and output latex code. It is very easy.
  1. Write equation
  2. Copy 
  3. Paste (latex code is automatically generated)
If you want to use this equation later using TeXaide, tick on the Edit->Translator->Include MathType data in translation. When you paste the equation, it will also paste a lines of commented weird text. These text is actually the one that you can paste into TeXaide and it will automatically translate into understandable equation.

See also: Equation in MS Word


LaTex Series: Table II

If you have tried latex, I'm sure you would pray someone could lend you a hand to create a beautiful tables. It is a nightmare to create table in latex. Luckily, we could use excel2latex macro in MS Excel and calc2latex in Calc. I'm not sure if calc2latex work with LibreOffice Calc.

Have fun "tabling"

Monday, February 3, 2014

LaTex Series: How to EPS

I spent a lot of time to figure out this eps stuff.

Cut the story short.

Save Powerpoint/Excel images as EPS

Method 1 (Recommended):

[Source via link here]

  1. Download and install LibreOffice
  2. Open a Powerpoint slide or Excel with LibreOffice
  3. Export it as a EPS file:
    • Powerpoint : File->Export->Choose EPS file type
    • Excel          : Right click an image->Export as Image->Choose EPS file type
  4. Open the generated EPS file with GhostView, and turn on menu "Option->EPS Clip and EPS Warn". Choose the menu "File->PS to EPS", allow the bounding box to be automatically calculated, and save with a different filename, say, figure_final.eps.

Method 2:

[Copy Paste via link here]

In case anyone needs to (e.g. for LaTeX compatibility)

These instructions are for windows 7.  See bottom of this page for older instructions I found somewhere on the Web.

Start button -> type in window "add printer"

in "add printer" dialog, go to:
 "add a local printer"
 in "choose a printer port", do "use an existing port" and select 'print to file'.
In "install the printer driver", select any PS printer, I chose HP ->  HP Color LaserJet 2800 Series PS

For printer name, chose e.g. "My Awesome .eps Printer Driver".
Do not share this printer.

When the wizard finishes and it is installed, type "print" (ctrl-P" from an Office program.  These instructions are for Office 2010.
I selected "My Awesome .eps Printer Driver", and just below that selector there is "printer properties" link.
Select that, choose "advanced tab", expand "PostScript Options", and for "PostScript Output Option", select "Encapsulated PostScript (EPS)" from the drop-down menu.

You can print with this driver to create .eps files.
Note that, at least from PowerPoint, the bounding-boxes may not be quite right (e.g. may correspond to the notional page rather than to your actual content).
I fixed this inside LaTeX with e.g.:

 \includegraphics[width=1.0\columnwidth,bb=60 215 705 755]{sgmm_fig}

These co-ordinates are upper-left (x,y), lower-right (x,y), I believe.  You can look at the .eps file in Ghostview and hover over the corners of your image to get the bounding-box co-ordinates (thanks to Mike Seltzer for this tip).

---
Comment from Rich Webb on how to automatically get these bounding box co-ordinates if you are using miktex:

Stop after the add-printer wizard completes. Do not go into the printer properties to change anything (I think that is what broke my earlier setup). Instead, just "print" through that virtual printer to .plt. This file is the plain-text PostScript job.

Run that file through ps2epsi (included in the MikTex distribution) from a command line as "ps2epsi .plt .eps". The resulting .eps file slides right into LaTeX with a bounding box that works perfectly for figures. Now if I can just convince it not to substitute Arial for Helvetica ...

Things to consider:
1) Place the figure on top left most of the slide. Otherwise, annoying white spaces will be haunting you forever as I had experienced. #grrrrrr
2) Rewrite the boundry box using notepad or similar editor. Save you the hassle of writing codes in latex.

Extra reading [graphics manual and another one here]

Other methods related to EPS can be found here

Convert PDF to EPS


  1. Open pdf file with inkscape
  2. Save as EPS
  3. In case you need to crop image area in inkscape, follow tutorial here




Friday, November 22, 2013

LaTeX Series: Thesis Template

I found a good website on thesis template. Feel free to go through the site.

How to LaTeX:
Figure

Monday, January 16, 2012

LaTeX series -- Adjusting float space

Sometimes, adjusting float (figure/table) can be really annoying!!!.... Especially when we used [hbt] command.... It adds white spaces that is very hard to deal with. Fortunately, I found the solution after some googling.

Space below top [t] and above bottom [b] floats is managed via the length \textfloatsep. Space above and below here [h] floats is managed via the length \intextsep.


\setlength{\intextsep}{10pt} % Vertical space above & below [h] floats
\setlength{\textfloatsep}{10pt} % Vertical space below (above) [t] ([b]) floats
\setlength{\abovecaptionskip}{10pt}
\setlength{\belowcaptionskip}{5pt}

But the above solution would affect the rest of the figure, once the command was executed. To change the behavior of white spaces for single figure, adding vertical space  \vspace{-2ex} or \vskip{-2ex} within the figure environment either before \end{figure} or just after \begin{figure} could solve the problem.

~Saved!!!

Tuesday, December 6, 2011

LaTeX series -- Figure

Konbawa!!!!.....

Well... LaTeX lesson is back!!!..

Today.... I got stuck on chart... well.... it is not really stuck.... I could convert text as figure if I MS word. However, I'm currently using LibreOffice that does not support this particular functionality. All I could do is to convert the chart to pdf file and convert to .eps file...

Well... it works but I was reluctant to admit that the quality of .eps file is quite low..  So, I spent "quite some time" (3 hours or so) to figure out on how to generate quality .eps file... Again... I was loath to install any software such as Inkscape which really capable of handling .eps file (generating/converting to .eps)...

To cut the story short.... I GIVE UP on trying to find the solution.... urmmm... the quality of pdf file is better in my opinion.... So.... What I did was:-

(a) Paste the chart generated in LibreOffice Writer into LibreOffice Draw
(b) Export as pdf
(c) Download pdf-cropper. Crop the white space.
(d) Replace \usepackage[dvips]{graphicx} with \usepackage[pdftex]{graphicx} *refer to LaTeX entry
(e) Add a new package \usepackage{epstopdf}
(f) Replace setting in Quick Build from "LaTeX + DviPs + Ps2Pdf + Pdf Viewer" to "PdfLaTeX + Pdf Viewer"

Now... everything is in order.... instead using .eps file for the figure... I will use .pdf file which could easily generated and much better in quality. I will stick with this setting for a while until I find a way to use .eps file effectively..... 

Until then..... Good luck for me!! :)


Update: Dec 8, 2011


Sometimes it's annoying to set up the figure placement if you want to use figure that span for two column {figure*} instead of {figure}. Well, there are solutions for this particular problem. You can use \usepackage{dblfloatfix} which actually a combination of package stfloats and fixltx2e. Placement control such as [tbp] can be used "correctly", though it depends on your document as well. The more figure*, the messy will it be.. 

Update: Jan 19, 2012

When using subfigure package, certainly we want to cite the figure in the main text and for IEEE the citation/reference would be something like "Fig. 1(a)". Using default configuration \ref{figure} would not work and will display "Fig. 1a". On the other hand, \subref{figure} will only display "Fig. (a)". Nevertheless, there is a simple twewak that I found to be useful and worked perfectly. Just add the following command and BOOM!!!... \subref{figure} command will now present you with "Fig. 1(a)" perfectly!!


\captionsetup[subfloat]{listofformat=parens}

~see LaTeX, LaTeX series -- Table

Monday, December 5, 2011

LaTeX series -- Table

Minna sann~..... genki desuka?!!

Jyaa~... kyou... oppss... tershashul pulop!!.... ari ni aku belajar Te-Form (て-Form) kat kelas... pening sket aar... bnyk sgt condition dia... basically apa yang aku faham....
verbs ます-Form boleh dipecahkan kepada 3 kelas... Group I, II & III.

Group II & III adalah mudah.... hanya perlu omit ますand replace with て. Untuk Group II, bunyi yang terakhir sebelum ます adalah "ee" (え). Perbezaan antara Group II & III hanyalah pada Noun+ます (Group II) dan Noun+します (Group III).... Sebagai contoh:-

Group II:-

みせます >> みせて
おしえます >> おしえて

Group III:-

べんきょうします >> べんきょうして
さんぽんします >> さんぽんして

Bagi Group I pula, agak sukar sedikit kerana banyak condition dimana ia bergantung kepada bunyi akhir sebelum ます. Eh.....!!

Macam silap entry je neh... huhuhuhu... ok ok... back to the topic...

Today, I've spent most of my time to figure out how to draw a nice table!!! It's quite challenging, especially for me who is very new to LaTeX... enough with talk... let's go straight to the point.. Alrite..

First thing, we need to determined how the table should be. For two column articles, would it be 1 column? span for 2 column? . Then, how many column would you like to have for the table etc... I'll only show what I've done today for my future reference :-)

\newcommand\T{\rule{0pt}{3.1ex}} % Adds a space between the text and the [T]op \hline
\newcommand\B{\rule[-1.7ex]{0pt}{0pt}} % Adds a space between the text and the [B]ottom \hline
\setlength{\doublerulesep}{\arrayrulewidth} %make \hline \hline as thick line

\begin{table*}[!t]  %span table for 2 column. Omit * if want to make table in 1 column
\caption{Title of the table}
\label{table_1}
\centering
%make 3 column, set alignment for column 1- left, column 2-right & column 3-center
\begin{tabular}{l r c} 
\hline \hline %bold horizontal line. Act as the table border


% \multicolumn{2}{c}-- meaning, span 2 column and centered
% \T \B -- meaning, add space for top and bottom
% \cline{2-3} -- meaning, make a line from column 2 until column 3
& \multicolumn{2}{c}{\textbf{Some Title}} \T \B \\ \cline{2-3}


% \multicolumn{1}{l} -- meaning, change alignment for column 1, from original right align to left align
% \hline -- meaning, make a horizontal line (thin)
\multicolumn{1}{l}{Some Parameters} & 2nd Parameter & 3rd Parameter \\ \hline 
& row1column2 & row1column3 \\ % "&" symbol at the beginning is used to skip 1 column
row2column1 \T \B & row2column2 & row2column3 \\ % end row 2
row3column1 \T &
% wrap long text using {minipage}. [t] is to set to the top align. {1.1in} is to set the length of minipage
\begin{minipage}[t]{1.1in} 
\begin{flushleft}a very long line for row3column2 a very long line for row3column2 a very long line for row3column2 a very long line for row3column2 \end{flushleft}%
\end{minipage} 
% wrap long text using \parbox. {1.3in} is the length of the \parbox. 
% {flushleft} -- meaning, to set the alignment to left
\parbox{1.3in}{\begin{flushleft}a very long line for row3column3 a very long line for row3column3 a very long line for row3column3 a very long line for row3column3 \end{flushleft}} \\
\hline \hline
\end{tabular}
\centering
\end{table*}

The output of above command as follow:-
From the table, you can see that the \parbox is quite difficult to handle. It's behavior is not as expected. Well, this is as far as I can do... for now..


Alrite.... I think it is enough for now.... we'll cont. some other time... I need to finish the unfinished business!!

じゃ。まった こんど

Update: Dec 8, 2011

Using \begin{flushleft} \end{flushleft} somehow leave unwanted vertical space in the cell and that is why \parbox is behaving wild. What I did was, use \usepackage{array} and change the setting my column to something like this:-


\begin{tabular}{l >{\raggedright}p{0.2\textwidth}  >{\raggedright\arraybackslash}p{0.3\textwidth}}
\toprule
row1column1 & row1column2 & row1column3 \\ \midrule
\bottomrule

\raggedright} is used to align the text to left.
\arraybackslash is required in order to make \\ works.
\toprule is required for \midrulerule\bottomrule and "" to works.



~see LaTeX

Sunday, December 4, 2011

LaTeX

Akhirnyaa............... berjaya jugak aku solve problem yang sepatutnya bukan problem... hahahhaa.... well... kalu blaja sendiri mmg camnih... the learning curve sometimes looks like stock market... up and down... and sometimes could hardly get the slope to +ve pattern... anyway... anyhow... maybe I just jot it down here in for future use... :)

Software:-
Ghostscript
GSView 
MiKTeX 2.9
TeXstudio 2.2

Ghostscript & GSView are essential to run LaTeX. Without these two softwares, LaTeX could also run but I would suggest to install them to avoid any unnecessary problems in the future... The installation is straight forward... Click and follow the instruction...

MiKTeX 2.9 is one the best software on windows platform... The installation also quite straightforward and could take sometime to finish. I strongly suggest to tick on the option "install missing plugin on-the-fly" (or the like) to ease up the installation process. Otherwise, you need to wait in front of the pc and click on every pop up that will come out for about 15-30 minutes.

TeXstudio 2.2 is a very userfriendly software for beginners. It will assist the user without the need to type full command as it will display the related command in "drop down list" as you type. You need to configure the Quick build to "LaTeX + DviPs + Ps2Pdf + Pdf Viewer" to allow .eps file to be displayed correctly using package "\usepackage[dvips]{graphicx}"

Sometimes, the template provided by the conference organizer ie. IEEE must be altered to meet the requirement set. You don't need to push yourself to edit .cls file but instead just use "\renewcommand"... For my case, I need to use "\renewcommand{\figurename}{Figure}" & "\renewcommand{\IEEEkeywordsname}{Keyword}" to set the figure caption as "Figure" instead of "Fig." and "Keyword" instead of "Key-Index"..

All command:-

\usepackage[dvips]{graphicx}
\renewcommand{\figurename}{Figure}
\renewcommand{\IEEEkeywordsname}{Keyword}

need to be loaded AFTER "\documentclass[conference]{IEEEtran}" call.

The rest could be "easily" learn :) from the template.... just follow the template provided....

I could rest happily tonite...

Peace!!! No War!!!
Kami Benci Rasuah!!!
Yang Salah Tetap Salah!!!