12
$\begingroup$

In Tabular is there any option that specifies that all Items are fully visible?

When I create the following Tabular using Tabular[{...data...},{...keys...}], I have to manually expand the columns.

enter image description here

$\endgroup$

1 Answer 1

8
$\begingroup$

The current implementation of auto-sizing for Entity columns is not perfect. It has two issues:

  1. The auto-sizing is only implemented for entities which are defined as Entity[type, spec], such as Entity["Country", "TrinidadTobago"]. However, it is not implemented for Entity[type, {specs}], such as Entity["City", {"Llanfairpwllgwyngyll", "Gwynedd", "UnitedKingdom"}].
  2. It will generally underestimate the width of the column, because it only looks at the string specification for Entity, which usually contains neither spaces nor the actual full name, ie. "TrinidadTobago" vs. "Trinidad and Tobago".

We can fix both issues by patching Tabular`Typesetting`TableView`Private`entityColumnWidth. It will take into account the actual display label for the entity.

tab = Tabular[{{Entity["Country", "TrinidadTobago"], 
    Entity["City", {"Llanfairpwllgwyngyll", "Gwynedd", "UnitedKingdom"}]},
   {Entity["Country", "UnitedStates"], 
    Entity["City", {"Johanngeorgenstadt", "Saxony", "Germany"}]}}]

(* Patch *)
Tabular`Typesetting`TableView`Private`entityColumnWidth[
   tc_?TabularColumnQ, TypeSpecifier["Entity"][_, "String", ___]] := 
  Tabular`Typesetting`TableView`Private`stringColumnEmWidth@
   TabularColumn[(EntityFramework`Formatting`Private`\
getTypesettingAssociation /@ tc)[[All, "Label"]]];
Tabular`Typesetting`TableView`Private`entityColumnWidth[tc_?TabularColumnQ, 
   TypeSpecifier["Entity"][_, 
    TypeSpecifier["ListVector"]["String", _], ___]] := 
  Tabular`Typesetting`TableView`Private`stringColumnEmWidth@
   TabularColumn[(EntityFramework`Formatting`Private`\
getTypesettingAssociation /@ tc)[[All, "Label"]]];

tab

enter image description here


Also note that there is a default limit set to the column width, which you can make larger.

Tabular`Typesetting`TableView`Private`$MaximumColumnWidth
(* 24 *)

tab = Tabular[{{ExampleData[{"Text", "UNHumanRightsEnglish"}]}}]

Tabular`Typesetting`TableView`Private`$MaximumColumnWidth = 100;

tab

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.