Wednesday, August 11, 2010

LaTeX formulas in XFig figures using PDFLaTeX

Hi,
this post is to explain how to insert mathematical formulas in figures created with XFig when using PDFLaTeX (and therefore when PSFrags is not an option). The procedure is actually so painless that I would recommend it even when PSFrags is available.
  1. when inserting the text in XFig, make sure you set the "Special text" flag. This can be done even after inserting the text by opening the Edit dialog window. You can mix normal text and math with the usual $ symbol.
  2. instead of exporting to PDF, export as "Combined PDF/LaTeX (both parts)". This will create two files figure00.pdf and figure00.pdf_t (assuming the name of the XFig file is figure00.fig).
  3. In your document, instead of using \includegraphics{figure00.pdf} include the _t file with \input{figure00.pdf_t}. If you want to resize the picture, you can use the command \resizebox as shown in the example below
  4. run pdflatex as usual.


Here are example files:
test.tex:

\documentclass{article}
\usepackage{graphicx}
\usepackage{color}
\begin{document}
Some text before the figure.
\begin{figure}
\resizebox{.5\textwidth}{!}{
\input{figure00.pdf_t}
}
\end{figure}
\end{document}

figure00.fig:

#FIG 3.2 Produced by xfig version 3.2.5b
Landscape
Center
Metric
A4
100.00
Single
-2
1200 2
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
0 0 1.00 60.00 120.00
1800 5490 1800 1395
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
0 0 1.00 60.00 120.00
315 5310 5535 5310
3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 4
585 5220 1980 5130 3195 4320 4545 1440
0.000 1.000 1.000 0.000
4 0 0 50 -1 0 12 0.0000 6 210 735 5040 5625 $\\alpha$\001
4 0 0 50 -1 0 12 0.0000 6 210 945 1935 1665 $e^\\alpha$\001

Enjoy!

Friday, August 6, 2010

TCP Window scaling may cause transfer problems

I noticed this problem first in Italy with an Alice Gate 2 Plus Wi-Fi modem and now I see a similar behaviour in Sweden with a NETGEAR Wireless Cable Voice Gateway modem used by ComHem. This made me think it was a good idea to rewrite in English my original post which was in Italian.

The symptoms (Alice Gate 2 Plus Wi-Fi):


- In GNU Linux this modem/router only works in modem modality, that is, by manually creating a pppoe connection with pppoeconf/pon/poff. If used as a router (automatic connection) web pages are only loaded partially or not loaded at all. Skype works in any case.
- In Windows 7, the router modality only works in combination with MS Internet Explorer (other browsers, such as Firefox and Chrome, show the same problem as in Linux)

The symptoms (NETGEAR Wireless Cable Voice Gateway):


- In GNU Linux the NETGEAR gateway works fine as long as browsing is concerned. When using SSH and many services using SSH, such as SVN, rsync, etc, sometimes the connection stalls and eventually times out
- I do not have a Windows computer in Sweden and could not check if the problem affects Windows as well, but, given the problems in saw in Italy, I would guess it does at least starting with Vista and newer versions.

The problem:


It seems that in both cases the routers do not handle properly the TCP option "window scaling" also called "receive window auto-tuning". This option is implemented in Linux and in Windows starting with Vista, and that is why the problem never occurred with Window XP or older.

The solution:


A solution is to disable window scaling in the TCP options, that is
- in GNU Linux open a terminal and run:
sudo sysctl net.ipv4.tcp_window_scaling=0
To make the option permanent, you have to add the line net.ipv4.tcp_window_scaling=0 in the /etc/sysctl.conf file.
- in Windows, start cmd as administrator and run:
netsh int tcp set global autotuninglevel=disabled

This may make the TCP protocol less efficient, so do this only if you encounter the problems described above.