Help talk:Table

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Wikipedia Help Project (Rated NA-class, Mid-importance)
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.
 NA  This page does not require a rating on the project's quality scale.
 Mid  This page has been rated as Mid-importance on the project's importance scale.
 

Strange table width behaviour[edit]

I'd appreciate an expert explaining to me why this edit made the table wider. I've built several of these tables -- see earlier in the same article, for example -- and the goal is to have minimal white space around the table entries, to avoid an unnecessarily wide table. The other examples in the article show what I'm trying to achieve. I tried removing the style=width entries and that didn't help. Evidently something is different about this table, but I can't figure out what it is. Thanks for any help. Mike Christie (talk - contribs - library) 20:08, 10 July 2016 (UTC)

I've kludged it by putting in a table width in pixels, but surely that's not the best answer. Mike Christie (talk - contribs - library) 20:14, 10 July 2016 (UTC)
Spring Summer Fall Winter
1988 50/1 50/2 50/3 50/4
2002 58/3 58/4 59/1 59/2
Issues of Weird Tales from 1988 to 2002, showing volume and issue numbers.
Note that the four issues starting with Summer 1994 were titled Worlds of Fantasy & Horror.
Spring Summer Fall Winter
1988 50/1 50/2 50/3 50/4
2002 58/3 58/4 59/1 59/2
Issues of Weird Tales from 1988 to 2002, showing volume and issue numbers.
Note that the four issues starting with Summer 1994 were titled Worlds of Fantasy & Horror.
@Mike Christie: The table is widened to display the single-cell bottom row without line wrapping. You could have placed a linebreak <br /> before the second sentence. The current version has so much content in the bottom row that limiting the whole table width may be a better solution. PrimeHunter (talk) 14:35, 11 July 2016 (UTC)
@PrimeHunter: I don't think that's the whole answer. You're right that putting in <br /> helps; I've done it before to good effect, e.g. here. However, there is some extra whitespace showing up at the right that I don't understand. See User:Mike Christie/Sandbox7; it has a <br /> in the caption but where is that extra space coming from? However, the table in the article itself is OK now, with the pixel limitation, so I'm asking now just to try to understand it. Mike Christie (talk - contribs - library) 14:53, 11 July 2016 (UTC)
@Mike Christie: I only see the width required to fit the longest line in the bottom row. I have Firefox 47.0.1. PrimeHunter (talk) 23:50, 11 July 2016 (UTC)
@PrimeHunter: I get this (the upper one is IE, the lower one is Chrome) when I display the table in the sandbox. If it looks OK in Firefox then perhaps it's a bug in the browser rendering? Mike Christie (talk - contribs - library) 00:11, 12 July 2016 (UTC)
@Mike Christie: I see the same as you in IE. I added two versions of the table here with widths removed in the second. In IE the first table is much wider and the second table is only as wide as required to avoid line wrapping in "Note ... Horror". In Firefox they both have that width. I don't know the reason for the IE rendering or whether it should be called a bug. Browsers have some freedom in rendering. PrimeHunter (talk) 13:09, 12 July 2016 (UTC)

Help at Channel Orange[edit]

I'm having no success with this table here, using "rowspan" so that the last line of items ("July 23, 2012"; "Universal Music Group"; "CD") also reaches the last row in the table ("France"). Can someone please help? Dan56 (talk) 22:10, 24 July 2016 (UTC)

@Dan56: "sortable" has problems with rowspans. Removing it would fix the issue. PrimeHunter (talk) 22:31, 24 July 2016 (UTC)

Problems with header cells[edit]

I'm having a slight problem while trying to build a table for a home video release of a TV series. For some reason, I can't seem to make the header cells or whatever you call them line up.

Expand to see malformed tables
{| class="wikitable" style="text-align: center; width: 98%;"
|-
! colspan="2" rowspan="2"| Set
! colspan="2" | Contents
|-
! Episodes !! Shorts
! Blu-ray / DVD artwork
! Bonus features
! Audio commentary
! BD / DVD release date
|-
| rowspan="1" width="1%" style="background: #778899;" |
| 1
| 
| 
| 
| 
| 
| 
|-
|}

renders as:

Set Contents
Episodes Shorts Blu-ray / DVD artwork Bonus features Audio commentary BD / DVD release date
1

For some reason, all the header cells after the double height one will not format correctly. When I try to make them the correct height by adding rowspan="2", thus

{| class="wikitable" style="text-align: center; width: 98%;"
|-
! colspan="2" rowspan="2"| Set
! colspan="2" | Contents
|-
! Episodes !! Shorts
! rowspan="2"| Blu-ray / DVD artwork
! rowspan="2"| Bonus features
! rowspan="2"| Audio commentary
! rowspan="2"| BD / DVD release date
|-
| rowspan="1" width="1%" style="background: #778899;" |
| 1
| 
| 
| 
| 
| 
| 
|-
|}

I end up with this:

Set Contents
Episodes Shorts Blu-ray / DVD artwork Bonus features Audio commentary BD / DVD release date
1

Does anyone know how to fix this? Ideally, I'd like a few more of these "nested header cells" or whatever you call them, but is that impossible? Thanks, G S Palmer (talkcontribs) 17:32, 28 July 2016 (UTC)

A cell must be specified in the row of the top part of the cell so "Blu-ray / DVD artwork" comes right after "Contents" like below. It's certainly possible to make more of the same type. PrimeHunter (talk) 19:30, 28 July 2016 (UTC)
Set Contents Blu-ray / DVD artwork Bonus features Audio commentary BD / DVD release date
Episodes Shorts
1
Thanks. G S Palmer (talkcontribs) 23:12, 28 July 2016 (UTC)
@PrimeHunter: Could you possibly demonstrate, on the "Audio Commentary" column? Because I still can't figure it out. I tried a few things, but they didn't work. I'm not good with tables. G S Palmer (talkcontribs) 23:31, 28 July 2016 (UTC)
Rowspan and colspan can be tricky. Only specify the cells that have their top in a given row, so there are no cells specified between "Shorts" and "Audio 1" below. PrimeHunter (talk) 23:41, 28 July 2016 (UTC)
Set Contents Blu-ray / DVD artwork Bonus features Audio commentary BD / DVD release date
Episodes Shorts Audio 1 Audio 2
1
Thank you very much. G S Palmer (talkcontribs) 01:22, 29 July 2016 (UTC)

Table split into columns[edit]

Hi, how do you split a table into two or more columns to avoid a long list and lots of white space? I'd like to do this to Regional League at this location [1] i.e. first column would be the 1944-45 to 1968-69 champions. Thanks. Eldumpo (talk) 06:58, 12 August 2016 (UTC)

One method is to make an outer table with one row and two cells, each containing a table. I did that in [2]. The tables are only sortable one at a time. I don't think it's possible to make the whole thing sortable with rows moving between the two columns when they are sorted. PrimeHunter (talk) 11:42, 12 August 2016 (UTC)
@PrimeHunter: Thanks very much. Eldumpo (talk) 08:13, 13 August 2016 (UTC)

Column width[edit]

Two questions:

  1. Why does the guide show how to specify column widths in pixels and then say that it's deprecated? I get why it's deprecated, but why give examples in a way that you don't want editors to use? It says to use ems instead but doesn't show how to do that.
  2. I've been trying in an article to line up the columns of consecutive tables using ems, but for some reason they're not consistent. Why is that? McLerristarr | Mclay1 07:12, 16 August 2016 (UTC)

Omitting the pipe between cell parameters and cell data[edit]

Resolved: When editing Comparison of single-board computers I noticed quite a few existing instances where there is no pipe (|) or vertical bar between the cell parameters such as rowspan and/or data-sort-value and the cell data. The table seems to display and perform correctly. It appears the parsing rules allow cell data to get populated by a template. Is this behavior something we can expect will always work or should that article get fixed up to always separate the cell parameters and cell data with a pipe or bar?

Below is an example table. None of the cells use a pipe or bar between the parameters and data including a rowspan for column 3. Nearly all of the cells have their data inserted via templates. The exception is the middle cell on the second row where the parser must have decided the entire thing was data.

Col 1 Col 2 Col 3
Cell 1-1 Cell 1-2 Cell 1/2-3
Cell 2-1 data-sort-value=10 Cell 2-2

--Marc Kupper|talk 08:15, 19 August 2016 (UTC)

@Marc Kupper: The pipe is always necessary but it may be added by a template. {{Yes}} and {{no}} in your example add background coloring and alignment so they already have cell attributes followed by a pipe followed by cell data. If the caller has cell attributes before these templates then there must not be a pipe. Their documentation says so in the lead. Your cell with data-sort-value=10 Cell 2-2 has no pipe and no template which adds a pipe so none of the text is cell attributes. PrimeHunter (talk) 10:51, 19 August 2016 (UTC)
Thank you! It had not occurred to me to read the manual for something that seemed as straightforward as a Yes/No. --Marc Kupper|talk 20:56, 19 August 2016 (UTC)

Tennis tables query[edit]

Most tennis stat tables follow the formatting I have in the top table here. The difference is that if we have a number column at all, the number column is after the result column. If I move the number column before the result column I don't want it to be colored at all. If I use white as background it's brighter than the rest of the default table color (I used F9F9F9 instead). Is there a simple way to suppress the No. column color that I'm missing? Thanks. Fyunck(click) (talk) 18:39, 26 August 2016 (UTC)

HTML does not have whole-column operations. Wikitext table code is just an alternative to HTML syntax and doesn't add such features. And I don't think it's possible in an individual cell to say "Ignore the row color and use whatever color would have been here otherwise. Note the color is different in the mobile version so the first column in your second table gets varying color, at least in my desktop browser: https://en.m.wikipedia.org/w/index.php?title=User:Fyunck(click)/sandbox/charts. I think the proper method would be to use no row color and instead add cell color for every cell where you actually want the color. That's a lot of color code. It could be added by a Help:Table#Row template so articles could just say something like {{Tennis final row|7|Loss|15 January 2015|P|[[Sydney International]], Australia|Hard|CZE|[[Petra Kvitová]]||6–7<sup>(5–7)</sup>, 6–7<sup>(6–8)</sup>}}. Then {{Tennis final row}} could add styling, flagicon and so on, and simultaneously change the styling in all articles using it. The "P" (for Premier) is the tournament category which should determine the background color. If wanted, "Loss" could also be shortened to "L", "Hard" to "H" and so on. PrimeHunter (talk) 20:54, 26 August 2016 (UTC)
I was afraid of that. No way would the project agree to have to add color to every cell, so I guess we're stuck with color in the number column. As far as shortening loss to "L" you have to realize that right this second it is actually Winner and Runner-up, and my shortening it to Win and Loss is already unlikely to fly. So W and L would likely be obliterated. Thanks, I just thought it looked better as an uncolored column. What the heck is the default color for tables at wikipedia anyway? It looks like F9F9F9 in my Firefox browser, but there must be a way to find out. Fyunck(click) (talk) 00:01, 27 August 2016 (UTC)
I mean the call of a row template could say "L" to shorten the code (or make it optional to say L, Loss or Runner-up). The template could then write Loss, Runner-up or whatever is wanted, and it could be changed later without changing all the articles. PrimeHunter (talk) 12:44, 27 August 2016 (UTC)
Also, I guess mobile versions color schemes are different. IE, Firefox, and Chrome desktop browsers all look perfect with F9F9F9 as the cell color. No variance that I can detect. But the mobile version you used does all wiki-background as "white", so I'd have to change it to "white" to match perfectly. Fyunck(click) (talk) 23:25, 30 August 2016 (UTC)

Japanese_pottery_and_porcelain#Wares table[edit]

I need help with the table please. The Kanji column needs more spacing so that all the Chinese characters fit into one line. What edit would be necessary? Thank you. Gryffindor (talk) 21:32, 2 September 2016 (UTC)

I used {{nowrap}} on the longest text in the column [3] to make it wide enough but not wider than necessary. PrimeHunter (talk) 22:30, 2 September 2016 (UTC)
Resolved Perfect, thank you very much. Gryffindor (talk) 23:08, 2 September 2016 (UTC)

An entire cell as a link?[edit]

Is it possible for an entire cell in a table to be a link itself, so rather than using [[A]] inside the cell, is there code that lets the whole cell from top to bottom, left to right be one big link? -- AxG /  10 years of editing 12:36, 24 September 2016 (UTC)

AFAIK, only in the usual way, by placing the cell's text to the right of a pipe after the intended link target:
no links here This will link to EN Wikipedia's Main Page – Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-- Michael Bednarek (talk) 12:45, 24 September 2016 (UTC)

Better way to do decimal point alignment?[edit]

While working on Atomic clock#Secondary representations of the second, I wanted to do decimal point alignment of a column to emphasize the order-of-magnitude differences between microwave and optical frequencies, and the nested table recommendation at Help:Table#Decimal point alignment is very awkward because you have to specify an explicit column width.

So I played around with CSS and came up with the following. (The example here is simplified by removing references and irrelevant columns.)

Atomic clock operating frequencies
Atom Frequency (Hz)
133Caesium 9 192 631 770  exactly
87Rubidium 6 834 682 610 .904 324
1Hydrogen 1 420 405 751 .766 7
87Strontium 429 228 004 229 873 .4

The column is actually two. The header cell specifies colspan=2, while the body cells specify style="text-align:right; border-right:none; padding-right:0;" and style="text-align:left; border-left:none; padding-left:0;", respectively.

This seems obviously superior to the nested-table construct, in particular letting the browser choose appropriate column widths, but before I go in and change the recommendation, can anyone see any reasons why it's not? E.g. should I leave the existing more awkward suggestion for some special cases? 71.41.210.146 (talk) 14:03, 27 September 2016 (UTC)

I just saw your edit on Atomic clock and found your formatting solution way more elegant than the previous nested table. I see no reason for not changing the recommendation. — Edgar.bonet (talk) 15:25, 27 September 2016 (UTC)
Okay, thanks, I'll WP:Be bold and change it. It's not like an edit is irreversible. 71.41.210.146 (talk) 17:13, 27 September 2016 (UTC)
It seems like a lot of code to use directly. I have made (not documented yet) {{alignd}} to align decimal numbers with the suggested code, and {{alignd column}} to be placed in other cells of the column. The below table looks the same as above but has simpler code. Templates also mean implementation details could be changed later. PrimeHunter (talk) 00:54, 28 September 2016 (UTC)
Atomic clock operating frequencies
Atom Frequency (Hz)
133Caesium 9 192 631 770  exactly
87Rubidium 6 834 682 610 .904 324
1Hydrogen 1 420 405 751 .766 7
87Strontium 429 228 004 229 873 .4
That's much neater, but "alignd" looks like a misspelling of "aligned". Perhaps something like "aligndp" would be clearer? -- John of Reading (talk) 06:17, 28 September 2016 (UTC)
I haven't tried it, but inspecting this code, and the previous, suggests to me that the full numbers cannot be sorted. If so, this should be mentioned in the documentation. If I needed decimal point alignment and sorting, I would use a right-aligned fixed-width font and a fixed number of decimals (which doesn't work well for vastly different orders of magnitude). -- Michael Bednarek (talk) 08:33, 28 September 2016 (UTC)
Sorting works surprisingly well when it just gets data-sort-type="number" in the header. My limited tests like the below sort correctly by the full number including decimals. PrimeHunter (talk) 10:15, 28 September 2016 (UTC)
Atomic clock operating frequencies
Atom Frequency (Hz)
133Caesium 9 192 631 770  exactly
87Rubidium 834 682 610 .904 324
1Hydrogen 1 420 405 751 .766 7
87Strontium 429 228 004 229 873 .4
1Hydrogen 1 420 405 751 .78
1Hydrogen 1 420 405 751 .7
Wow, I'm indeed surprised, and withdraw my previous uninformed remarks unreservedly. -- Michael Bednarek (talk) 12:24, 28 September 2016 (UTC)

Help on table creation[edit]

Hello,

What's the right way to create a table for production figures?

I'd like to create a new monthly production table for the T-34 article. However, the tables on Soviet combat vehicle production during World War II gave me a rough idea, thought, I want it closer to the orginial as depicted in the book. Have a look on the picture: http://i.imgur.com/QCCHaRi.jpg

I've started with some tryouts on my sandbox, but, I'm not sure if I'm doing it right: https://en.wikipedia.org/wiki/User:Dircovic/sandbox

Would love to have some help! Thanks in advance. Dircovic (talk) 07:26, 12 November 2016 (UTC)

Diagonal split header[edit]

Hi, I have a quick question regarding the {{diagonal split header}} template: is there a similar template for the diagonal line going "the other way" (i.e. top-right to bottom-left)? Skewb? (talk) 23:53, 2 January 2017 (UTC)

@Skewb?: I don't think so but it could be made. What is it for? PrimeHunter (talk) 00:32, 3 January 2017 (UTC)
@PrimeHunter: It's not for anything important (though maybe it could be useful in the future). I just want to experiment with different shapes of tables on my sandbox, but I don't think there's any way of creating a diagonal split (either in the header or anywhere else) except for the above template. Skewb? (talk) 21:17, 3 January 2017 (UTC)
@Skewb?: A similar template to the above could certainly be made, or the type of code it uses could be written directly in a table. But the template uses an ugly hack to achieve it and diagonal "splits" in the other direction seem far less useful. The generated html is one cell with a diagonal line where the template just tries to guess how to position two different texts so they end up on each side of the line without an unnatural position in their triangle. Users of the template may have to add additional blankspace to avoid crossing the line. Other browsers, font settings, printers and so on may render it differently, and I imagine it's confusing to screen readers (see MOS:DTAB). Without a good use case I don't think it should be done. PrimeHunter (talk) 11:15, 4 January 2017 (UTC)
@PrimeHunter: Fair enough, I personally don't have an issue with writing the code itself directly into the table. I'm not very good at coding though, so could you please let me know what the code for diagonal lines (in both directions) would look like? Skewb? (talk) 12:55, 4 January 2017 (UTC)
@Skewb?: You can try Special:ExpandTemplates to see the code {{diagonal split header}} generates and then tinker with it. PrimeHunter (talk) 01:28, 5 January 2017 (UTC)