Removing white space in a table - latex

I am having an issue with too much white space. Here's a picture of my data fields with placeholders representing the largest digit count possible in them.
As you can see, after the last "P" the values escape the scope of the chart. While I could increase the size of the table as a whole (currently textwidth), that would be a poor design choice on my part. What I'm thinking is to utilize all of that wasted white space. I don't know what to do though.
When I have all single digit values, the table looks perfect. I want the increased number size to "consume" the white space before forcing the table out of it's defined bounds.
I was hoping using extracolsep with no arguments would remove whitespace, but it sadly does not.

try adding this command before your table;
\renewcommand{\tabcolsep}{1pt}
the default column separator width is 6pt inserted before and after column contents, but this will change that. Replace 1pt with whatever you need.

Related

How to append alpha characters in a spreadsheet (google sheets)?

I have a string: "region" in a cell. I would like to have a column automatically populate with:
regionA
regionB
regionC
regionD
I have found that by using "char(row(A65)" and then fill down I can auto populate alpha characters.
This works:
=concatenate(B12, char(row(A65)))
(b12 has the "region" string)
But when I do fill down it not only increments the A65 but also increments B12.
How do I have it only increment one part of this function?
I'm also open to other ways of doing this, anything that works.
If you add a $ before a part of the range, that part stays fixed or static.
So either
=concatenate(B$12, char(row(A65)))
or
=concatenate($B$12, char(row(A65)))
can be dragged down, and the B12 won't change. $B$12 could also be dragged sideways without changing.
Try:
=ARRAYFORMULA(B12&CHAR(SEQUENCE(4)+64))
The '4' will determine how many rows you are spilling down. Obviously this works up to 'Z'.
If you want to extend this further then try:
=ARRAYFORMULA(B12&REGEXEXTRACT(ADDRESS(1,SEQUENCE(100),4),"\D+"))
The '100' will determine the amount of rows you spill down.

How to delete empty cells and shift up in Google Sheets?

Is there a way to delete empty cells in a given range and shift the column up to the desired display as shown below? Closest I came was
=ARRAYFORMULA({A1:C1; TRANSPOSE(SPLIT(TRANSPOSE(QUERY(A2:C,,999^99)), " "))})
which removes empty cells, but splits the first names and surnames into separate cells, which I have not figured out how to avoid. Pfa a made-up sample of current and desired displays:
Current Display
Desired Display
I'm new at this, but I came up with a bit of a brute force method, which may help you.
={
{(A1:C1)};
{FILTER(A2:A100,A2:A100<>"");indirect("N1:N" & 100-counta(A2:A100))},
{FILTER(B2:B100,B2:B100<>"");indirect("N1:N" & 100-counta(B2:B100))},
{FILTER(C2:C100,C2:C100<>"");indirect("N1:N" & 100-counta(C2:C100))}}
Assuming your data block is in columns A1:C100, this formula filters blank cells from each individual column, and then pads each column with blank cells at the bottom, to make the three arrays equal in length/dimension.
Note that in "100-counta(...", the 100 is the expected maximum length of your data column.
This could be calculated, and must be the same for all three columns.
Note also that the first array is horizontal (ends with a semi-colon), followed by the three columns, stacked beside each other (ends with a comma).
Here is a working example.
https://docs.google.com/spreadsheets/d/1MGaqqGrkmIliuAzEqxPtdEVZXWPN2K5W7jFFM-ZnwgE/edit?usp=sharing
If I missed something you were trying to achieve, let me know.
Also, I'm sure that there is a more elegant way to do this, or one not requiring the use of a block of "reserved" blank cells, but I couldn't think of that at the moment.
Edit: The formula as follows also works. But you need to remember to set the "100" value to be equal to the number of rows in your data block, since we pad the columns with the necessary number of blanks rows, after removing the blank cells in each column.
={
{(A1:C1)};
{FILTER(A2:A,A2:A<>"");indirect("N1:N" & 100-counta(A2:A))},
{FILTER(B2:B,B2:B<>"");indirect("N1:N" & 100-counta(B2:B))},
{FILTER(C2:C,C2:C<>"");indirect("N1:N" & 100-counta(C2:C))}}

Google sheets; Arbitrary range as string

How to convert a range of arbitrary size, to it's string representation, to be later used using INDIRECT ?
ADDRESS only works for a single cell.
No scripting please :)
Only formulas.
EDIT 1 ;
Also assume the range is computed through a complex formula. So no cell addresses are available.
EDIT 2 ;
=ArrayFormula(IF((OFFSET(INDIRECT(PayStaff),0,10)>PayrollStart)*(OFFSET(INDIRECT(PayStaff),0,10)<=PayrollEnd),(OFFSET(INDIRECT(PayStaff),0,10)-PayrollStart),0)+IF((OFFSET(INDIRECT(PayStaff),0,11)>=PayrollStart)*(OFFSET(INDIRECT(PayStaff),0,11)<PayrollEnd),(PayrollEnd-OFFSET(INDIRECT(PayStaff),0,11)),0))
No sample sheet as this is a hypothetical type question.
Above is an actual formula I'm using, one of many in my efforts at fully automation. At any time, the range string in "PayStaff" can change, coupled with repeated but identical OFFSET calls, soon makes the formula unreadable. One of my ideas to solve the readability is to get the range-string of (eg: OFFSET(INDIRECT(PayStaff),0,10) ) and reuse it, shortening the formula and increasing readability. Also note, the example does NOT have size increase of range which I require as well.
But lets suppose that PayStaff = "A1:A10", where the number of rows can vary. Considering that OFFSET has 4 parameters, how to get the resultant range as a string? Is this possible?
I just used this to do something similar, hope this helps:
// <range here> = is the range you want to describe,
// can be output of some other formula but has to be a
// rectangle for this to work.
// Remove // comments and line breaks before pasting to sheet.
// concatenate top left corner with colon and bottom right corner.
=CONCATENATE(
// use address to get top left corner
ADDRESS(ROW(<range here>), COLUMN(<range here>)),
":",
// use address to get bottom right corner
ADDRESS(
ROW(<range here>)+ROWS(<range here>)-1,
COLUMN(<range here>)+COLUMNS(<range here>)-1
)
)
This would give you the start of the range as a string:
=cell("Address",OFFSET(INDIRECT(PayStaff),0,10))
The end of the range is more awkward - you would have to add the number of rows in the range (-1) to the row offset:
=cell("Address",OFFSET(INDIRECT(PayStaff),rows(indirect(PayStaff))-1,10))

How to set jira table's column width

I struggled with this question for some time and was able to find the solution. The idea is that my script automatically generates a data, puts it into table and there are some columns that should preserve their width (should not be less then something). But jira markup sets table column width dynamically basing on screen resolution and data that is preserved in all the table columns. And noformat for data cells did not help me because there was some symbols in those columns that required jira markup. I am not jira admin so using advanced plugins and jira scripts is not an option.
Solution was to set the table headers names with noformat. If you need a wider table, just add some spaces to the header and wrap it in noformat. And jira will keep the column width basing on that preformatted header.
So example would be:
||{noformat}Header1 {noformat}||Header2||{noformat} Header3 {noformat}||Header4||
|data1|data2|data3|data4|
....
In this example the width of columns with header2 and header4 will be generated dynamically depending on which's content is longer (the column width could be even set dynamically to 1 symbol). While width of header1 and header3 will never be smaller then the length of the column name.
This solution does not allow to set the width of the column, but at least it allows to make some columns to be wide enough to show data correctly.
Since noformat does not look very pretty, i got anonther solution here, which probably is the prettiest one (when you look at the result and not the markup):
I just created a transparent image with a size of 1x1px and inserted it in the column headers with the minimum size I wanted the columns to be. In order to make the header text vertically centered, I needed to insert it before and after the text. See the following example:
|| !transparent.png|width=300px, height=1px! Col1 !transparent.png|width=300px, height=1px! || Col2 || Col3 ||
|| Row header | Content of column 1 | Content of column 2 |
A lot of HTML non-breaking line spaces.. i.e.
so a header will contain code like this..
|| Field Description ||Reserved Field||
It's a bit icky but it works in shifting the centre and expanding the column width. sadly this is limited to other content too but a lot prettier than {noformat}. Doesn't allow fixed sizing but better than squashed columns
e.g.
Formatted table with better column width
Jira seems to expand the width of the right column to fit the contents, and this can squeeze the left column so that it doesn't fit it's contents.
A workaround for this particular issue is to restrict the width of content in the right column until the left column has enough width to render properly.
One way to do this is to enter new lines into the content.
|| Parameter || Meaning ||
| a term | A definition which contains
lines breaks.|
The {noformat} solution did not work for me and I don't have admin access to add a plugin, so I created a Chrome extension to set the minimum column width to 100 pixels. Kind of silly that it had to come to this but it gets the job done.
https://chrome.google.com/webstore/detail/jira-table-width-fixer/lgbgknkgpchdholdabagddphgaildolf/related
Brain-dead brain dead solution: fill header with underscores. The "noformat" trick was too ugly even for me, the didn't work, I don't have permissions (or I'm too lazy) to find/use/install a transparent jpg... So I just used underscores. Making the header text "space-less" ("dont_squish_me" instead of "dont squish me") prevents Jira from line wrapping.
|| build || dont_squish_me || really_long_field____________________________________ ||
| [22|http://jenkins/job/JOB/22] | 5:27:50 | some extra text that might wrap |
| [23|http://jenkins/job/JOB/23] | 4:19:22 | more wrappable |
I googled for invisible unicode character, which is not a space, thus JIRA won't trimm it. The first I found and copy pasted in visuell mode while editing the table header of a JIRA comment, did the magic and I could adjust the needed column width. (Although I had to replace my spaces in the text if there were any or any other whitespace characters which could make JIRA break my header into more lines.
This was the unicode character I used: https://www.compart.com/de/unicode/U+2800
(copy the text from the box)
You should place them all in the same table for the columns widths to be the same (do not provide any space tables); for example
||Table1Col1||Table1Col2||Table1Col1Comment|Table1Col2Comment|
||Table2Col1||Table2Col2||Table2Col1Comment|Table2Col2Comment|
Hoepfully this should work.

Detect text columns from word positions

I have a tiff file and the text on it, which has been OCR'd at an earlier stage. The words have their exact positions as information (upper left, lower right). I now need to read the text within a user-drawn rectangle.
Normal paragraphs are no problem, but I don't know how I should handle text columns. If there are two paragraphs next to each other, simply taking the row as a single line would make the result unusable.
Are there algorithms to help me put the words in the right order? I'm guessing that I have to examine the spaces between words to detect patterns that identify columns. I would like to avoid processing the image directly, although it should be possible (but no OCR).
I am also unsure about the influence of lists/tables, e.g. in orders & bills. A line-orientated approach would probably be better here.
I am developing in Delphi, but adaptable algorithms in other languages would also be appreciated.
edit: I will try to post sample data tomorrow, but basically I have an Array of Words, with their respective coordinates on the image (I could easily draw a rectangle around them, for example).
Suppose your original text is in two columns like this:
Aaaa bb ccc ddddd mmmm nn oooo pp
eee fff ggggg hh qqq rrrrrrrrr
i jjjj kkk lll sss tttt uu.
From your description, it sounds like your OCR has given you the individual words and their bounding rectangles. If the original page is scanned orthogonally, then all of the words on a given line should have the same (or very close) y values. If they're not exactly the same, you can do an integer division on the vertical positions with some fraction of a typical box height. That should cluster the y values. You can do similar processing on the x coordinates to ensure that words at the edge of a column also have identical x values.
To detect the separate columns, I'd try making a histogram of all the "left" values of all the words (or right edges if your text runs right-to-left). You should see a peak at the beginning of each column.
You can probably rule out any false positives by ensuring that, on every line, there is a gap between the right coordinate of the last box before the candidate start of a column. The gap should probably be at least as large as the smallest width of any word.
You can then partition your words up into column groups by checking which horizontal range their left and right coordinates fall in to. In our example, the words from Aaaa through lll would end up in the first partition and the words from mmmm through uu. would end up in the second partition.
Within each partition, you can then partition on line by sorting on the y coordinates. Finally, for each line, you sort on the x coordinate. (Whether you sort on ascending or descending depends on your coordinate system and the direction your text flows.)
The same basic idea could be applied to tables as well as columns of text, but you might need some tweaks to deal with things like right-justified cells.

Resources