So in dual monarchy systems leaders have 2 titles, like Kaiser Karl the 1st of Hungary and 4th of Austria. Is there a particular way to order the names? Does it go highest to low or vice versa (like above)? Also if a leader was overthrown but returned to the throne before their death would they still have their previous number? For example, if Queen Elizabeth the Second was forced to abdicate today, and then through some strange set of circumstances in a couple years she reclaimed the throne would she still be called Queen Elizabeth the 2nd? Is there any situation where she wouldn't be called such or any she would? This is probably a stupid question and I'm most likely overthinking things, but i was just curious
Just to add to what had already been said, its must first be established that different kingdoms had differing rules regarding Regnal Numbers, and only a few had been codified.
In the example of Britain, a classic case that tested this concept was MacCormick v Lord Advocate, [2] wherein the Rector of the University of Glasgow, John MacCormick, legally challenged Queen Elizabeth II’s right to use the “2” regnal number, as there hadn’t been a Queen Elizabeth before in Scotland and by doing so, technically she breached the rights and terms established in the Acts of Union 1707 that had combined the formerly separate Kingdoms of England, Scotland, Ireland and other domains to form the United Kingdoms of England, Scotland, Ireland, Wales and Berwick-upon-Tweed. [4] (It was shortened to the United Kingdoms of England, Scotland and Ireland after the Wales and Berwick Act 1746) [3]
Now going back, the case was decided that the regnal number of the United Kingdom would use the highest number that was available in the official records of kings and queens of the Kingdoms of England and Scotland. [1] For example, If there be another King James, he would be crowned as James VIII, as in the Scottish reckoning, as there was already 7 King James that have reigned, even if there was only 2 previous King James in the English throne.
Similar cases would be if there would be:
A King William (the next king will be known as William V per the English reckoning)
A King David (next king would be King David III per Scottish reckoning)
A King Alexander (next king would be King Alexander IV per Scottish reckoning)
A King Constantine (next King would be King Constantine IV per the Scottish reckoning)
In the case of the Dual Monarchy of Austria-Hungary, their respective traditional regnal numbers applied since the thrones of the Archduchy of Austria and the Kingdom of Hungary were co-equals, and unlike the British tradition after the Act of Union 1707, there is actually a need to display both numbers as part of the unresolved Austro-Hungarian Compromise of 1867. That is why Karl (or Charles) I & IV is the actual proper rendering of his majesty’s imperial titles, even if in Bohemia (a Kingdom under the Austrian half of the empire) he would be known simply as Karl III, since in Bohemian records he is the third king to reign in that name.
EDIT: I forgot to add why it was "Charles I and IV" in the first place. To clarify, the Austrian title {the "Charles I" part)" is their primary title and goes first in convention, somehow similar to a primus inter pares (first among equals) position. The Hungarian title (the "Charles IV" part) goes second, and has a point of contention that even though the Hungarian and Austrian titles were supposed to be co-equals, this positioning was somehow symbolic that the Hungarian throne still goes second to the Austrian one. This is also why the two King James dual numbers are also titled as they are (James VI and I, James VII and II). They were originally Scottish monarchs (hence making the Scotland their primary title, which goes first) who inherited the English throne second, and thus this awkward system was resolved by the Act of Union 1707, simplifying the system to follow English reckoning and regnal numbers until the MacCormick v Lord Advocate decision.
Many had been said already about the question of a pretender returning to a throne, but the question of continuity is interesting since even in France today, there are the royalist pretenders who still continue their regnal numbers in an unofficial, record-keeping capacity. For example, the current Napoleonic pretender to the French throne is Napoleon VIII, or properly known as Jean-Christophe, Prince Napoleon. Meanwhile, the current Orleanist pretender to the French throne is Jean IV, properly known as Jean Carl Pierre Marie d’Orléans, Count of Paris, and the Légitimisme pretender is Louis XX, properly known as Louis Alphonse de Bourbon, Duke of Anjou. If any of these men somehow succeed to the French throne (if the French Fifth Republic falls and an imperial government is proclaimed in France), they would use their current title of pretense (Napoleon VIII, Jean IV, Louis XX) as their proper imperial title and regnal number to emphasize continuity.
Sources
[1] ROYAL STYLE AND TITLE, HC Deb 15 April 1953 vol 514 cc199-201, Hansard. Link: https://api.parliament.uk/historic-hansard/commons/1953/apr/15/royal-style-and-title
[2] MacCormick v Lord Advocate Digest, Link: https://en.wikisource.org/wiki/MacCormick_v_Lord_Advocate
[3] Blackstone, William. The rights of persons, according to the text of Blackstone : incorporating the alterations down to the present time 1894, p.92 Link: https://archive.org/details/bub_gb_fdoDAAAAQAAJ/mode/2up
[4] Act of Union 1707, PDF copy provided by parliament.uk Link: https://www.parliament.uk/documents/heritage/articlesofunion.pdf
EDIT: Spacing
In terms of the ordering of titles, they generally go in the order in which they were acquired. For example, James VI was of course the sixth dude named James to be king of Scotland. When he inherited the throne of England, he became the first James to be king of England, and so he became James VI and I.
However, subsequent rulers in such arrangements theoretically inherit all of their deceased parents titles simultaneously, so what happens in such circumstances? If that is the case, then the titles usually become ordered by the prestige of each title.
For example, James VI and I great-grandson, also named James, became the king of Scotland and England in 1685, so how does he arrange his titles since he inherits them all at the same time? Since England was the seat of government, wealthier, and the more powerful of the two states, his status as the King of England is listed first, and so he is known as James II and VII. For another example of this, Kaiser Karl Hapsburg was also the Count of Hapsburg, which was the first noble title held by his family. But obviously this title is much less prestigious than many of his other titles, so even though it was the first one received by his family, it was a great deal further down the huge list of titles than the much more prestigious Imperial and Royal titles.
As for the second question. When monarchs are overthrown or abdicate, they may keep some sort of title depending on the circumstances. If the monarchy ceases to exist as an office, then they probably will be using a new name outside of royalist or reactionary circles. For example, King Louis XVI was just referred to as 'Citizen Louis Capet' when the monarchy was abolished and he was awaiting trial. Kaiser Wilhelm II retired to the Netherlands after his abdication and and the end of the German Empire, and he just went by 'Mr. Wilhelm Hohenzollern'. If the monarchy still remains, and if the former monarch is still in the good graces of the government or the people then they would probably keep a title. When Edward VIII abdicated he was given the title Duke of Windsor. This is not a hard and fast rule though, Queen Beatrix of the Netherlands abdicated in 2013 and no longer has a royal title.
Now in our theoretical overthrow followed by restoration, would the monarch change their title. As a general rule, Monarchs like to emphasize their continuity with previous monarchs as a way to boost their legitimacy. For example, when poor Louis XVI's brother was restored to the French throne, he was crowned King Louis XVIII, even though his nephew, the alleged Louis XVII, had never actually been coronated, or ruled as king of anything before he died of neglect. That was how important showing continuity was to the restored Bourbons. For another example. When Emperor Napoleon was deposed and then was briefly restored to rule over France, he did not become Emperor Napoleon II, he was still just Emperor Napoleon.
Hope this long-winded response answered your questions!