Help talk:Table

From Wikipedia, the free encyclopedia
Jump to: navigation, search
the Wikipedia Help Project  
WikiProject icon This page is within the scope of the Wikipedia Help Project, a collaborative effort to improve Wikipedia's help documentation for readers and contributors. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks. To browse help related resources see the help menu or help directory. Or ask for help on your talk page and a volunteer will visit you there.
 ???  This page does not require a rating on the project's quality scale.
 ???  This page has not yet received a rating on the project's importance scale.
 

Table Overflows Into Right Margin[edit]

In the Safari browser on an iPad in the Cladograms section a table overflows to the right edge of the right margin and pushes the right edge of the margin to the right, expanding the right margin to nearly half the page. The entire text of the article is squeezed into the left half of the page.

I see this effect in other articles, e.g., a table in the Vocabulary comparison section of the Romance Languages article, but don't know how to fix it. — Preceding unsigned comment added by 173.72.170.69 (talkcontribs) 15:50, 4 December 2011‎

Clean up table of contents // Restructure[edit]

This help page has too many unordered information in it. I'd suggest a massive clean-up. If you dont want to delete whole sections, just improve nesting of headlines. Check these headlines - very hard to understand IMHO (sections 9-16):

9 Other table syntax
     9.1 Comparison of table syntax
 10 Pipe syntax in terms of the HTML produced
     10.1 Tables
     10.2 Rows
     10.3 Cells
     10.4 Headers
     10.5 Captions
     10.6 Summaries
 11 Square monitors
 12 Vertically oriented column headers
 13 Wikitable as image gallery
     13.1 Shifting/centering
 14 Generate a chart with a table
 15 Converting spreadsheet to wikitable format
 16 Tables and WYSIWYG -- — Preceding unsigned comment added by Jesus Presley  (talkcontribs) 19:31, 25 November 2012

Question on sorting[edit]

Letter Number
A 4
6
B 1
5
C 3
2

In a sortable table like the above one, when you click on the second any column's header to sort by that column's contents the contents of the cells of the first column will be split and doubled. Is there any way to code such a table that it only splits if you sort on the second column and that if you sort back on the first column after having sorted on the second column the cells that were split in two are merged again to their original state? Tvx1 02:20, 1 March 2015 (UTC)

@Tvx1: No. You would need to file a feature request at phab:. --Redrose64 (talk) 23:28, 1 March 2015 (UTC)
@Redrose64:, could you give me some advice on how to file such a request in a good manner? Tvx1 00:16, 2 March 2015 (UTC)
If you follow that link, you should find near the top a box titled "Getting Things Done", containing two links, "Report a Problem" and "Phabricator Help". I would start there. --Redrose64 (talk) 00:20, 2 March 2015 (UTC)
Yes, I can find how to report a bug, but I can't find any information regarding requesting a feature. Tvx1 00:32, 2 March 2015 (UTC)
"Report a Problem" is also used for feature requests. See more at mw:How to report a bug#Reporting a new bug or feature request (the method there reaches the same link as "Report a Problem"). Sorting issues are better discussed at Help talk:Sorting than here at Help talk:Table. I don't know whether your issue has been discussed before. PrimeHunter (talk) 00:56, 2 March 2015 (UTC)

Putting image and table into a single line[edit]

When a table is not very wide, it takes up a lot of vertical space for not much material. I am wondering if it is possible to place a table inline, so that text flows around it (without turning it into an image), or else to share a single line between a table and an image. I can do the latter through nested tables, but these are discouraged.

Is there any other way to do either of these things? Here is the table:

Recognized independent Waldorf schools by continent
Continent Schools Countries
Africa 22 5
Asia 58 12
Europe 692 34
North America 150 3
Oceania 52 2
South America 67 6

And here is the image it could share a line with:HGilbert (talk) 13:06, 30 March 2015 (UTC)

Growth of Waldorf schools
Growth in the number of accredited Waldorf schools in the world from 1919 to 2012

Recognized independent Waldorf schools by continent
Continent Schools Countries
Africa 22 5
Asia 58 12
Europe 692 34
North America 150 3
Oceania 52 2
South America 67 6
Growth of Waldorf schools
Growth in the number of accredited Waldorf schools in the world from 1919 to 2012
Try style="float:left;".
Look at the source. --Mrjulesd (talk) 13:26, 30 March 2015 (UTC)
Perfect; thanks! HGilbert (talk) 13:49, 30 March 2015 (UTC)

Help resizing table[edit]

Hi, I'm having trouble resizing List of municipalities in Ontario#Local municipalities using the following code since the columns resize automatically to some default regardless how I set the width manually.

"{|class="wikitable sortable" ! scope="col" width="50px" | Name"

I'm trying to shrink the columns to allow the images to straddle on the right of the table, as in this similar page List of municipalities in Alberta

Any help would be greatly appreciated. Mattximus (talk) 18:06, 9 May 2015 (UTC)

First, never assume that anybody else's screen is the same width as yours. The chances are that it's not: so even if you get a table to look "right" on your screen, it will probably look wrong for other people. For that reason, it's best to avoid fixed column widths altogether, and let the other person's browser arrange the columns to suit the available space on that screen.
If you can't get away from set column widths, don't set an absolute width like 50px - you don't know the font size on the other machine, it may turn out that 50px is too narrow, even for a short word like "Name". So use percentages instead. When setting percentage widths, make sure that those columns that you do give a width to add up to less than 100%, and always leave at least one column unsized, this is to make sure that the browser can still adjust where necessary. --Redrose64 (talk) 20:09, 9 May 2015 (UTC)
Whether or not images straddle on the right of the table doesn't have to much to do with the coding of the table. It's a result of the size of you're browser's window. I can go from the images stocking on top to the images nicely straddling next to the table to a massive whitespace in-between the table and the images on the right just by expanding my browser's window. Tvx1 11:50, 10 May 2015 (UTC)
Thanks for your replies. So it seems there is no way to code a table so that the images straddle nicely to the side on most monitors? Mattximus (talk) 22:12, 12 May 2015 (UTC)
The problem is how we are going to define "most monitors". I even if we are able to do so, not every user who has the same size of monitor is going to use the same screen resolution setting on that monitor.

uneven rowspans[edit]

is there any easy way to make a table with the following layout?

+-----+-----+
|     |     |
| 1.1 |     |
|     | 1.2 |
+-----+     |
|     |     |
| 2.1 +-----+
|     |     |
+-----+     |
|     | 2.2 |
| 3.1 |     |
|     |     |
+-----+-----+

my attempts to do this with rowspans summing to 6 have failed for some reason. thank you. Frietjes (talk) 17:14, 11 May 2015 (UTC)

follow up, very odd but this
{| class="wikitable"
| rowspan=2 | 1.1
| style="display:none"|
| rowspan=3 | 1.2
|-
| style="display:none"|
|-
| rowspan=2 | 2.1
| style="display:none"|
|-
| style="display:none"|
| rowspan=3 | 2.2
|-
| rowspan=2 | 3.1
| style="display:none"|
|-
| style="display:none"|
|}
works, but if I remove the fake cells, it doesn't work. Frietjes (talk) 17:20, 11 May 2015 (UTC)
Have a look at how I did it at {{rail line three to two}}. Basically, you need to have six rows. --Redrose64 (talk) 18:35, 11 May 2015 (UTC)
I have a similar problem with a table. This is how it looks now:
Team A Team B
Cliff Morgan (1970–75) Henry Cooper (1970–79)
Fred Trueman (1976–77)
Brendan Foster (1977–79)
Gareth Edwards (1979–81) Emlyn Hughes (1979–81)
Bill Beaumont (1982–96) Willie Carson (1982–83)
Emlyn Hughes (1984–88)
Ian Botham (1988–96)
John Parrott (1996–2002) Ally McCoist (1996–2007)
Frankie Dettori (2002–04)
Matt Dawson (2004–present)
Phil Tufnell (2008–present)
It should look like this:
+--------------------------+---------------------------+
|       '''Team A'''       |        '''Team B'''       |
+--------------------------+---------------------------+
|Cliff Morgan (1970–75)    |                           |
+--------------------------+                           |
|Fred Trueman (1976–77)    |Henry Cooper (1970–79)     |
+--------------------------+                           |
|Brendan Foster (1977–79)  |                           |
+--------------------------+---------------------------+
|Gareth Edwards (1979–81)  |Emlyn Hughes (1979–81)     |
+--------------------------+---------------------------+
|                          |Willie Carson (1982–83)    |
|                          +---------------------------+
|Bill Beaumont (1982–96)   |Emlyn Hughes (1984–88)     |
|                          +---------------------------+
|                          |                           |
+--------------------------+Ian Botham (1988–96)       |
|                          |                           |
|John Parrott (1996–2002)  +---------------------------+
|                          |                           |
+--------------------------+                           |
|Frankie Dettori (2002–04) |Ally McCoist (1996–2007)   |
+--------------------------+                           |
|                          |                           |
|Matt Dawson (2004–present)+---------------------------+
|                          |Phil Tufnell (2008–present)|
+--------------------------+---------------------------+
My efforts to achieve this were all in vain, even with the fake cells. Tvx1 21:04, 28 May 2015 (UTC)
Please give a link to where you carried out your testing. --Redrose64 (talk) 21:52, 28 May 2015 (UTC)
Ian Botham and John Parrott share a row in your code but that row renders with height 0 for me. Same for the row shared by Ally McCoist and Matt Dawson. The below looks OK for me in a Firefox test but may change display in other circumstances. It uses height to force some multi-row cells to a certain height. PrimeHunter (talk) 22:31, 28 May 2015 (UTC)
Team A Team B
Cliff Morgan (1970–75) Henry Cooper (1970–79)
Fred Trueman (1976–77)
Brendan Foster (1977–79)
Gareth Edwards (1979–81) Emlyn Hughes (1979–81)
Bill Beaumont (1982–96) Willie Carson (1982–83)
Emlyn Hughes (1984–88)
Ian Botham (1988–96)
John Parrott (1996–2002)
Ally McCoist (1996–2007)
Frankie Dettori (2002–04)
Matt Dawson (2004–present)
Phil Tufnell (2008–present)
I use Firefox: and the above comes out uneven. Setting an explicit height makes assumptions, which you shouldn't do when laying out a table. The characteristics of your system are not the same as everybody else's.
{{rail line three to two}} works by having a column (two in fact) with no rowspans at all, each of the six cells in that column contain a   to force some height into each row. They appear to be a single 6-high cell because the top five cells have the bottom border removed, and the bottom five cells have the top border removed, so that the five common borders are absent. --Redrose64 (talk) 22:57, 28 May 2015 (UTC)
The table I pasted here is just one attempt I made to make it work (and it seems I didn't even correctly coded the Parrot-Botham row). This is how it was originally coded:
{| class="wikitable"
|-
! Team A 
! Team B
|-
| [[Cliff Morgan]] (1970–75) 
| rowspan=3|[[Henry Cooper]] (1970–79)
|-
| [[Fred Trueman]] (1976–77) 
|-
| [[Brendan Foster]] (1977–79) 
|-
| [[Gareth Edwards]] (1979–81) 
| [[Emlyn Hughes]] (1979–81)
|-
| rowspan=3|[[Bill Beaumont]] (1982–96) 
| [[Willie Carson]] (1982–83)
|-
| [[Emlyn Hughes]] (1984–88)
|-
| [[Ian Botham]] (1988–96)
|-
| [[John Parrott]] (1996–2002) 
| rowspan=3|[[Ally McCoist]] (1996–2007)
|-
| [[Frankie Dettori]] (2002–04) 
|-
| rowspan=2|[[Matt Dawson]] (2004–present) 
|-
| [[Phil Tufnell]] (2008–present)
|}
I tried to apply the "fake cells" to that, but it didn't work obviously. I didn't test in any sandbox or so. I just edited it and used the preview button to check whether it worked and cancelled the edit altogether when I noticed it didn't. That means I can't provide a link to anything, unfortunately. Any of course in this one too the Parrot-Botham row isn't correctly coded yet. Tvx1 23:40, 28 May 2015 (UTC)
The fake cell approach leads to something like this. Not particularily better I think, or at least not how I worked it.
Team A Team B
Cliff Morgan (1970–75)  
Fred Trueman (1976–77) Henry Cooper (1970–79)
Brendan Foster (1977–79)  
Gareth Edwards (1979–81) Emlyn Hughes (1979–81)
  Willie Carson (1982–83)
Bill Beaumont (1982–96) Emlyn Hughes (1984–88)
   
  Ian Botham (1988–96)
John Parrott (1996–2002)  
   
Frankie Dettori (2002–04) Ally McCoist (1996–2007)
   
   
Matt Dawson (2004–present) Phil Tufnell (2008–present)
   


--Jules (Mrjulesd) 00:07, 29 May 2015 (UTC)

Well at least that table is correct. The only issue that one has is that some cells are larger than needed. Tvx1 22:05, 29 May 2015 (UTC)
Using style heights, but tweaking slightly gives this:
Team A Team B
Cliff Morgan (1970–75) Henry Cooper (1970–79)
Fred Trueman (1976–77)
Brendan Foster (1977–79)
Gareth Edwards (1979–81) Emlyn Hughes (1979–81)
Bill Beaumont (1982–96) Willie Carson (1982–83)
Emlyn Hughes (1984–88)
Ian Botham (1988–96)
John Parrott (1996–2002)
Ally McCoist (1996–2007)
Frankie Dettori (2002–04)
Matt Dawson (2004–present)
Phil Tufnell (2008–present)
Perhaps a slight improvement. --Jules (Mrjulesd) 11:28, 31 May 2015 (UTC)
Indeed, but now the Dawson-McCoist shared row is hardly noticable. Tvx1 13:52, 31 May 2015 (UTC)
@Tvx1: how about this?
Team A Team B
Cliff Morgan (1970–75) Henry Cooper (1970–79)
Fred Trueman (1976–77)
Brendan Foster (1977–79)
Gareth Edwards (1979–81) Emlyn Hughes (1979–81)
Bill Beaumont (1982–96) Willie Carson (1982–83)
Emlyn Hughes (1984–88)
Ian Botham (1988–96)
John Parrott (1996–2002)
Ally McCoist (1996–2007)
Frankie Dettori (2002–04)
Matt Dawson (2004–present)
Phil Tufnell (2008–present)
Not improved probably. I would try to tweak the height until is seems correct, but it's a little difficult to get exactly right, it doesn't seem to work how I predict for some reason. May also vary between browsers. --Jules (Mrjulesd) 16:16, 31 May 2015 (UTC)
No. now the McCoist, Dawson and Tufnell cells are way to large and Parrot and McCoist no longer share a row. I highly appreciate your efforts but I'm not sure this is the right way to solve this. I still wonder why the original table doesn't appear the way it's coded? It has a rowspan of 2 for Matt Dawson, but only one row appears. Similarly it has a rowspan of 3 for Ally McCoist, but only two appear. Tvx1 16:36, 31 May 2015 (UTC)
Parrot and McCoist do share a cell, at least on my system, but you're right it probably isn't an improvement.
I think the reason rowspan doesn't work correctly is that whoever programmed it didn't envisage this overlapping of cells, and did it purely as perfectly lined up cells, but cells lining up with more than one cell. They should have really, there was no reason for this not to work as originally envisaged, but I don't think they basically thought of this situation, and didn't implement it properly. Or at least that's a probably explanation.
Having said, I would just pick whichever one you like best and go with it. Or maybe the help desk / village pump would have more luck. --Jules (Mrjulesd) 16:56, 31 May 2015 (UTC)

wikitable[edit]

I will be deleting User:Gadget850/wikitable in a few weeks. If anything seems useful, grab it and use it. -- Gadget850 talk 23:04, 27 May 2015 (UTC)

Is it OK if I move it instead? I was thinking of Wikipedia:Catalogue of CSS classes/Wikitable or something. Btw I hope you enjoy your retirement. --Jules (Mrjulesd) 22:12, 28 May 2015 (UTC)

Where is class=wikitable not used?[edit]

Hi, I'm wondering what are the most common situations/instances, where class="wikitable" is not applied? Is there a particular subset of articles, or templates, that frequently use either a bare table, or a table with a specific alternative class? Thanks! Quiddity (WMF) (talk) 00:34, 19 June 2015 (UTC)

Lots. for example, {{infobox}} {{navbox}} {{sidebar}} {{side box}}, the nine or so boxes in the {{mbox}} group, and that box at the bottom of {{documentation}} that begins "The above documentation is transcluded from ...". --Redrose64 (talk) 08:26, 19 June 2015 (UTC)
Also {{track listing}} --Redrose64 (talk) 08:26, 22 June 2015 (UTC)
Thanks Redrose64. Are there any/many uses for it in just mainspace? (I shouldn't have included the "or templates" in my original question! >.< ) I'm particularly asking regarding phab:T85577, and whether to give mainspace tables this class by default. Cheers. Quiddity (WMF) (talk) 21:13, 24 June 2015 (UTC)
I've notified Wikipedia:Village pump (technical)/Archive 137#Where is class=wikitable not used?, a page with considerably more watchers. --Redrose64 (talk) 21:29, 24 June 2015 (UTC)
Hmph. Zero responses (even I got here by watching this page, not via VP). Border-free tables in mainspace must be rare, or a WP:DGAF matter. I suspect that using class wiktable by default would be OK in mainspace, on Wikipedia, as long as it's easily overridden. Mainspace use of borderless tables (other than for short-term outright abuse of tables as a clumsy layout device by noobs) is rare, and I've yet to see a case that couldn't be replaced with |class="wikitable". It's probably marginally preferable that some don't use lines, like {{tracklisting}}, but those can always override the default style. We probably get more net positive out of making it a default and instantly beautifying loads of crappy tables than we lose in productivity fixing a few table templates to override the wikitable styles. But I might be underestimating the workload.  — SMcCandlish ¢ ≽ʌⱷ҅ʌ≼  14:14, 12 July 2015 (UTC)

Column sum[edit]

Is there such a function in wikitables to sum the values of a particular column? There are thousands of tables with numbers that have a sum as the final row, and I recently found using excel that many are incorrect. Is there a function in wikitables to do this automatically? Mattximus (talk) 13:11, 30 June 2015 (UTC)

No. Some tables use #expr to compute the sum but editors have to manually copy each number to the expression. It could for example be {{#expr:4+7+23}} to produce 34 if there are three cells containing 4, 7, 23. If a cell is changed without updating the corresponding number in #expr then the sum becomes wrong. PrimeHunter (talk) 13:31, 30 June 2015 (UTC)
(edit conflict) Not as far as I know. Wikitables are essentially HTML with some careful styling, and in HTML no element (such as a table cell) has knowledge of the contents of another element. It might be possible using JavaScript; that is how we provide the sorting facility. --Redrose64 (talk) 13:31, 30 June 2015 (UTC)
Unfortunately my javascript skills are not at that level, but I want to thank both of you for your quick reply! Mattximus (talk) 14:15, 30 June 2015 (UTC)
@Mattximus: You can also use a template-built table to feed values to #expr, e.g. some regional demographics and a statistic to divide by:
{{#expr: ( {{formatnum:{{{demo1|}}}|R}} + {{formatnum:{{{demo2|}}}|R}} + {{formatnum:{{{demo3|}}}|R}} + ... ) / {{formatnum:{{{stat1|}}}|R}} }}
Used like:
{{TemplateNameHere
|demo1=3,823
|demo2=1777.98
|demo3=-19334.32
...
|stat=5.829333
}}
So, a value does not have to manually passed (and changed in two places) to get a total, but just be added to (or changed in) the template once, as long as no idiot substs the table template, and no other idiot inputs an invalid, non-numeric value like "approx. 175" or a division by zero. Lots of templates do this already.  — SMcCandlish ¢ ≽ʌⱷ҅ʌ≼  15:10, 12 July 2015 (UTC)

Cleanup[edit]

I did several hours of line-by-line cleanup, fixing bad CSS markup and other sloppy coding, several outright errors, mistakes in grammar/punctuation, unclear sentences, unclear examples, and a bunch of other stuff. I also flagged a few places where we are using deprecated markup and need to write better examples, mostly to stop trying to force specific pixel sizes, which has been stupid since, oh, the mid 1990s. Also removed two instances of dead code (e.g. crap dating back to 2007–08 that's been moot for years). I'm out of patience to fix the px stuff myself; it takes getting a sense of what em size will approximate what px size, though there are online converters to do this stuff. My eyes just hurt too much after all this code-poring.  — SMcCandlish ¢ ≽ʌⱷ҅ʌ≼  14:05, 12 July 2015 (UTC)

@SMcCandlish: Your edit summary for this edit says "CSS errpr" (presume typo for "CSS error"), but there were no errors in the code that you altered. In a style="..." attribute, a semicolon is only necessary between two declarations; it's optional after the last one (and indeed before the first one), so adding a non-mandatory semicolon does not fix any CSS error. --Redrose64 (talk) 06:58, 13 July 2015 (UTC)
Meh. Technically true if you want to nitpick, but it's a strongly-recommended best practice to include it, and about 80-90% of the code already did include it. It's recommended because things tend to break when it's missing, especially in a scripted (or "templated" as we call it) environment where additional code can be injected. On WP we have the additional problem that we have thousands of editors, a large number of whom are not CSS experts and do not realize the semicolon is ever needed, and who will attempt to add CSS declarations without understanding they have to be semicolon-separated. We should do everything we can to help them. This includes consistently written code, too, and another issue I fixed (about 1/4 of the CSS declarations were run-together in one or more ways, while the rest were spaced for clearer readability, and I normalized them to the latter style).  — SMcCandlish ¢ ≽ʌⱷ҅ʌ≼  07:33, 13 July 2015 (UTC)