{"id":99865,"date":"2018-10-01T07:00:00","date_gmt":"2018-10-01T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=99865"},"modified":"2019-05-21T19:43:39","modified_gmt":"2019-05-22T02:43:39","slug":"20181001-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20181001-00\/?p=99865","title":{"rendered":"Generating a table with vertical text, like I did with the sad history of the C++ <CODE>throw(&#8230;)<\/CODE> exception specifier"},"content":{"rendered":"<p>In <a href=\"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20180928-00\/?p=99855\">The sad history of the C++ <code>throw(...)<\/code> exception specifier<\/a>, I presented some tables with vertical text. Here&#8217;s how I did it. (I simplified the table a bit to allow me to focus on the part that does the vertical text.)<\/p>\n<pre>&lt;TABLE BORDER=1 STYLE=\"border-collapse: collapse\"&gt;\r\n&lt;TR&gt;\r\n    &lt;TH COLSPAN=2&gt;Specifier&lt;\/TH&gt;\r\n    &lt;TH&gt;Standard behavior&lt;\/TH&gt;\r\n    &lt;TH&gt;Microsoft behavior&lt;\/TH&gt;\r\n&lt;\/TR&gt;\r\n&lt;TR&gt;\r\n    &lt;TD ROWSPAN=2&gt;\r\n        <span style=\"color: blue;\">&lt;SPAN STYLE=\"writing-mode: vertical-lr;\r\n                     -ms-writing-mode: tb-rl;\r\n                     transform: rotate(180deg);\"&gt;Nonthrowing&lt;\/SPAN&gt;<\/span>&lt;\/TD&gt;\r\n    &lt;TD&gt;&lt;CODE&gt;noexcept&lt;\/CODE&gt;&lt;BR&gt;\r\n        &lt;CODE&gt;noexcept(true)&lt;\/CODE&gt;&lt;\/TD&gt;\r\n    &lt;TD&gt;&lt;CODE&gt;std::terminate&lt;\/CODE&gt;&lt;\/TD&gt;\r\n    &lt;TD&gt;&lt;CODE&gt;std::terminate&lt;\/CODE&gt;&lt;\/TD&gt;\r\n&lt;\/TR&gt;\r\n&lt;TR&gt;\r\n    &lt;TD&gt;&lt;CODE&gt;throw()&lt;\/CODE&gt;&lt;BR&gt;&lt;\/TD&gt;\r\n    &lt;TD&gt;&lt;CODE&gt;std::terminate&lt;\/CODE&gt;&lt;\/TD&gt;\r\n    &lt;TD&gt;&lt;CODE&gt;std::terminate&lt;\/CODE&gt;&lt;\/TD&gt;\r\n&lt;\/TR&gt;\r\n&lt;TR&gt;\r\n    &lt;TD ROWSPAN=2&gt;\r\n        <span style=\"color: blue;\">&lt;SPAN STYLE=\"writing-mode: vertical-lr;\r\n                     -ms-writing-mode: tb-rl;\r\n                     transform: rotate(180deg);\"&gt;Throwing&lt;\/SPAN&gt;<\/span>&lt;\/TD&gt;\r\n    &lt;TD&gt;&lt;CODE&gt;noexcept(false)&lt;\/CODE&gt;&lt;\/TD&gt;\r\n    &lt;TD&gt;exception propagates&lt;\/TD&gt;\r\n    &lt;TD&gt;exception propagates&lt;\/TD&gt;\r\n&lt;\/TR&gt;\r\n&lt;TR&gt;\r\n    &lt;TD&gt;&lt;CODE&gt;throw(something)&lt;\/CODE&gt;&lt;\/TD&gt;\r\n    &lt;TD&gt;not supported&lt;\/TD&gt;\r\n    &lt;TD&gt;not supported&lt;\/TD&gt;\r\n&lt;\/TR&gt;\r\n&lt;\/TABLE&gt;\r\n<\/pre>\n<p>Here&#8217;s the result:<\/p>\n<p><!-- The style sheet for this site messes with the cell padding,      so I have to restore it manually. --><\/p>\n<table class=\"cp3\" style=\"border-collapse: collapse;\" border=\"1\" cellpadding=\"3\">\n<tbody>\n<tr>\n<th colspan=\"2\">Specifier<\/th>\n<th>Standard behavior<\/th>\n<th>Microsoft behavior<\/th>\n<\/tr>\n<tr>\n<td rowspan=\"2\"><span style=\"writing-mode: vertical-lr; -ms-writing-mode: tb-rl; transform: rotate(180deg);\">Nonthrowing<\/span><\/td>\n<td><code>noexcept<\/code><br \/>\n<code>noexcept(true)<\/code><\/td>\n<td><code>std::<\/code><code>terminate<\/code><\/td>\n<td><code>std::<\/code><code>terminate<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>throw()<\/code><\/td>\n<td><code>std::<\/code><code>terminate<\/code><\/td>\n<td><code>std::<\/code><code>terminate<\/code><\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\"><span style=\"writing-mode: vertical-lr; -ms-writing-mode: tb-rl; transform: rotate(180deg);\">Throwing<\/span><\/td>\n<td><code>noexcept(false)<\/code><\/td>\n<td>exception propagates<\/td>\n<td>exception propagates<\/td>\n<\/tr>\n<tr>\n<td><code>throw(something)<\/code><\/td>\n<td>not supported<\/td>\n<td>not supported<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The first trick is to use <code>writing-mode: vertical-lr<\/code> to get the text to run vertically. By itself, the text runs top to bottom, but we want it to run bottom to top, so we spin it around it with the <code>transform: rotate(180deg)<\/code>. The default transform origin is the center of the element, so this works out great.<\/p>\n<p><b>Update<\/b>: Also add <code>-ms-writing-mode<\/code> for Internet Explorer.<\/p>\n<p>The second trick is applying those attributes to an inner <code>SPAN<\/code> element, rather than on the parent <code>TD<\/code>. This gets the box calculations right for the table cell.<\/p>\n<p>You can apply colors to the various table cells if you want a colored table.<\/p>\n<p>Here&#8217;s the same table in wikitable form, because I had need for that too.<\/p>\n<pre>{| class=\"wikitable\"\r\n|-\r\n! colspan=\"2\" | Specifier\r\n! Standard behavior\r\n! Microsoft behavior\r\n|-\r\n| rowspan=\"2\" | &lt;span style=\"writing-mode: vertical-lr; -ms-writing-mode: tb-rl; transform: rotate(180deg)\"&gt;Nonthrowing&lt;\/span&gt;\r\n| &lt;code&gt;noexcept&lt;\/code&gt;&lt;br\/&gt;&lt;code&gt;noexcept(true)&lt;\/code&gt;\r\n| &lt;code&gt;std::terminate&lt;\/code&gt;\r\n| &lt;code&gt;std::terminate&lt;\/code&gt;\r\n|-\r\n| &lt;code&gt;throw()&lt;\/code&gt;\r\n| &lt;code&gt;std::terminate&lt;\/code&gt;\r\n| &lt;code&gt;std::terminate&lt;\/code&gt;\r\n|-\r\n| rowspan=\"2\" | &lt;span style=\"writing-mode: vertical-lr; -ms-writing-mode: tb-rl; transform: rotate(180deg)\"&gt;Throwing&lt;\/span&gt;\r\n| &lt;code&gt;noexcept(false)&lt;\/code&gt;\r\n| exception propagates\r\n| exception propagates\r\n|-\r\n| &lt;code&gt;throw(something)&lt;\/code&gt;\r\n| not supported\r\n| not supported\r\n|-\r\n|}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s how I did it.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-99865","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>Here&#8217;s how I did it.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/99865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=99865"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/99865\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=99865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=99865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=99865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}