Doing a habilitation in Mathematics in Europe for a non EU citizen? I'm a non-EU citizen, currently doing a postdoc in mathematics in Europe, and I'm thinking of doing a habilitation. Since my google search didn't yield much, I'd appreciate if you could please answer my following questions regarding habilitation:

1) If I understand correctly, habilitation is the highest academic degree you can receive and people do it for getting a permanent academic position in Europe.
How many years or how much/many publication does it normally take to obtain a habilitation degree?

2) Since you could be admitted as a PhD candidate, but not as a 'habilitation candidate' (but instead, say, as a postdoc) can you publish in your postdoc and write the paper(s) as a book and submit it for the defense of habilitation?

3) Suppose you do a one year postdoc in university A, and a second in university B, can you apply to university B for habilitation? How about university A?

4) If you do your PhD and postdoc in unrelated areas, or say even if you switch from pure to applied math, would that be a problem for getting the degree?

5) (Kind of vague question, somewhat opinion-based too) How much does the chance of getting a European tenure increase if you do a successful habilitation?
I'm starting this by answering some questions for Germany:


  1)  people do it for getting a permanent academic position in Europe.


Note that even being a professor does not imply a permanent position:


junior professorships run 6 years, and according to Wikipedia only 8% of the junior professorships can be considered proper tenure track (applying for a permanent position at the same university without a public job advertisement), for another 4-10% of the junior professorships it is possible to apply for a permanent position at the same university, the remaining majority will not be considered for a permanent position.
"Hausberufungen" ("in house appointments" = offering the professorship to someone from the same university) are somewhere between extremely uncommon (having a fishy taste) and forbidden. 
Also regular professors can have a probation period before getting a permanent position.



  How many years or how much/many publication does it normally take to obtain a habilitation degree?


A junior professorship is 6 years and is supposed to be an equivalent alternative to the habilitation, I think that gives a first rough estimate. Besides, I'd recommend that you look into habilitations in your field: they are published in the respecive university libraries and nowadays usually available electronically. 


  2) Since you could be admitted as a PhD candidate, but not as a 'habilitation candidate' (but instead, say, as a postdoc) can you publish in your postdoc and write the paper(s) as a book and submit it for the defense of habilitation?


Cumulative habilitations are very common. Again, look at some in your field.


  3) Suppose you do a one year postdoc in university A, and a second in university B, can you apply to university B for habilitation? How about university A?


No idea. But the habilitation is supposed to show that you can teach the whole field and one distinguishing criterion (from dissertation) is that also the presented research must cover some breadth. 


  4) If you do your PhD and postdoc in unrelated areas, or say even if you switch from pure to applied math, would that be a problem for getting the degree?


Not sure, but as a habilitation in maths means that you are allowed to teach all kinds of maths I guess that would not be a problem. I know physicists and engineers who habilitated in chemistry (though doing the scientific work in a chemical institute). 


  5) How much does the chance of getting a European tenure increase if you do a successful habilitation?


Well, in practice in order to become a professor you either need a habilitation or become junior professor (for 6 years) and then successfully apply for a professorship. 


number of habilitations / year is about 1600. Approximately 650 professors are pensioned / year, so  approximately 1/3 of the people who habilitate actually become professor
Update for maths &amp; natural sciences: ca. 160 profs pensioned / ca. 260 habilitations per year => would correspond roughly to a 60 % chance.
roughly 3% (total: 1439) of all professors (43 862) are junior professors, that is aproximately 240 new per year.
Maths &amp; natural sciences: 305 of 7500 = 4%, corresponding to ca. 50 / year.
Wikipedia says that somewher between 1/3 and 2/3 of the junior professors work at their habilitation despite being junior professors.


Here's what the Statistische Bundesamt says about these subjects.