Automatic "entry" column in LaTeX tables - latex

I was wondering if it is possible with LaTeX to create a table with multiple rows and columns and have an automatic "entry" column in every table? This means I would like the first column of every table saying "entry" and numbering the rows of the column from 1 to n. (I hope that kind of explains what I want to achieve).
I will need to refer to single entries in a column and it would be easier to have that numbering done automatically in case I change the order of the rows later on.
Is there any way to do that or a package to make that work?
I am new to the whole LaTeX thing so please be easy on the technical terms :)

Check out this TeXBlog post.
You want to create a counter using \newcounter, set it to zero using \setcounter, then at the beginning of each row, increment the counter and print out its value. The example I linked to makes use of a nifty feature of the tabular environment where, in specifying the format for a column, you can also specify a piece of code to be included before each cell in that column. This saves you from having to duplicate the code, as is done in this example.

Related

Google Sheets - Randomize and freeze queried columns

I'm trying to create a dynamic 'worksheet' in Google Sheets to help myself study Chinese.
This is something I'm kind of figuring out as I go, but I'm currently trying to create a template for the basic 'worksheet' that will draw vocabulary from other pages in my document.
Here's a copy of my current version: https://docs.google.com/spreadsheets/d/1U1hclOSo-SM2JuxJB6LXPB4J0UzXt6xJ1B_54ehkALs/edit?usp=sharing
Sheet1 is where I'm currently struggling. The idea behind Column A was that I could create 'switches' to keep the page from updating (Freeze) while I'm actually using the worksheet for studying. Once I've finished and checked my work, I could switch back to (Update) so that the Query will re-run and update to include any new words, etc.
Thus, E2 =if(A2="Update",1,0) is the condition I'm trying to check. 1 in this case would be letting the page update. 0 would be the only other value (Freeze), which would ideally stop the sheet from updating.
Another problem I've run into is that I wanted to use the 'Randomize Range' feature from the right-click menu on the output of my Query, but that doesn't seem to work. I wanted to be able to shuffle the terms so that I am not accidentally memorizing the order rather than the actual information I'm trying to learn.
I don't know which is more efficient: Having the Query grab the definition along with the word and add those to a hidden column, or have a column that matches the word to its definition outside of the Query.
If I could add in another layer of complexity, it would be neat if I could have my worksheet randomly choose between column A and column D (maybe E, too) on my Vocabulary Bank pages so that sometimes it would show me the English term and other times it would show me the Chinese one. (Currently, I'm planning to just have one worksheet for English to Chinese and a second for Chinese to English.)
In the end, I'd like for Sheet1 to work like this:
Column A: Switches
Column B: Terms, grabbed from 'Vocabulary Bank - [etc.]'!A3:A [etc.] being all of the different banks. These are randomly reordered and 'frozen' until the Range switch is changed to 'Update'.
Column C: Hidden, containing the translations of the corresponding words. These update according to a switch.
Column D: This is where I enter my guesses at the translations. There is a switch to enable 'grading' where answers that don't match Column C are highlighted.
Any help would be appreciated. Thanks!

Number increment in Google Sheets formula

In a Google Sheets database, I have a formula which I have built in order to allocate a reference number to a series of companies.
Each company should have its unique number in the form of RET00XX where XX will represent the unique company number. I would like these numbers to be sequential, starting on 1 and going on +1 after that.
Whenever a new company is inserted in the database, the formula should be able to attribute it a reference number. It should also be able to verify if the company already exists in the database and, if so, automatically attribute it the company's unique reference number, instead of creating a new one.
The company names are in cells of column B.
This is the formula I have built (an example of the one in row 2):
=ARRAYFORMULA(IF($B2<>"",IF((COUNTIF($B$1:$B1,$B2)>0),INDEX($A$1:$R2,MATCH($B2,$B$1:$B1,0),12),CONCATENATE("RET00",ROW($B2))),""))
The steps it takes are:
It verifies that column B in the correspondent row is not empty;
With the COUNTIF function, verifies that the company does not exist in any of the previous rows;
If the company does exist, it attributes the correspondent reference number through the INDEX function;
If the company doesn't exist, it attributes the company a new reference number with the CONCATENATE and ROW functions.
The formula is largely working, although there are some problems.
Users adding to this database have the habit of adding entries by inserting rows in the middle of the database. This makes it so, due to the way the formula is built, that company unique reference codes change each time that happens. I believe this is partially due to the fact that I use a ROW function. Also, given that new rows are inserted in the middle of the database, the formula should be able to verify is the company already exists not only by looping through all previous rows but rather through all rows (if a new row is inserted, the formula will only verify previous rows, when the company could be in the rows after the new one).
How can I attribute sequential numbers in a formula without reference to ROW? Also, how can I make sure that the spreadsheet verifies for all rows of column B instead of just the ones before the inserted row?
apply this formula in your sheets,
=ArrayFormula(if(B2:B<>"",row(A2:A)-1,""))
More information regarding this please visit this link : https://infoinspired.com/google-docs/spreadsheet/auto-serial-numbering-in-google-sheets/
Solution that is independent of starting row number
These examples will allow you to generate incrementing values in your formulas.
Incrementing integers, zero based:
The values will be: 0,1,2,3, etc.
Note: The address "$A$2" represents the cell of your top row. It should be changed to whatever cell your actual top row is. The nice thing about this method is it it will not break if you insert new rows above the start position of your formula.
=(ROW()-ROW($A$2))
Integers, one based:
The values will be: 1,2,3,4, etc.
=(ROW()-ROW($A$2) + 1)
Dates:
The values will be: 2000-01-01,2000-01-02,2000-01-03, etc.
=Date(2000,1,1) + (ROW()-ROW($A$2))
All Even Numbers:
The values will be: 0,2,4, etc.
=(ROW()-ROW($A$2) * 2
Short answer
Use Google Apps Script
Explanation
Using spreadsheet functions to set an ID on a live spreadsheet used as a database is very risky as the values will be recalculated when changes be made to the spreadsheet content.
Instead of using a formula use a script to add a "fixed value". Scripts could be called automatically on events like cell edits and row insertion, by using a custom menu or side panel, from the script editor or by time-driven triggers.
The following Q&A from Web Applications shows several ways to set a sequential number:
Can I add an autoincrement field to a Google Spreadsheet based on a Google Form?
This other from SO could be helpful too:
Auto incrementing Job Reference
Insert 1 in the first cell and paste the formula below in the following cells.
=INDIRECT(ADDRESS(ROW()-1,COLUMN())) + 1
Add number on very first row and type the formula from next cell
i used =A1+1 to get incremental number to index tasks on each line.

Google Spreadsheets : how do i manage the automatic increment when extending formula to other cells?

I have, I hope at least, a very simple question.
I have a simple sheet with the 3 first columns being a table of results, and a bunch of options that I can fill in some columns on the right. Obviously, the values in the table are supposed to change when I change the different options.
The formulas are very simple : =B2+F9 (each value in the table is based on the previous entry, the first one being specified in the options.
When I select the cell, grab the little square on its bottom right and drag it down it generates something like this :
=B2+F9
=B3+F10
=B4+F11
=B5+F12
It's basically incrementing each reference... wich is the probem I face as the F9 reference is an option and should not change.
What I want basically is something like :
=B2+F9
=B3+F9
=B4+F9
=B5+F9
Thus incrementing the B column, but not the F9 cell.
I tried to "hard-write" some of the first cells, kind of telling him "keep this F9" but without any success :(
How am I supposed to do this ? :'(
Use absolute references for that. In your case, you'd have the following:
=B2+F$9
The $ symbol means that the row is absolute, and should not change when you extend the formula. So, it would generate:
=B2+F$9
=B3+F$9
=B4+F$9
...
If you want the column to be fixed, you can reference it like $B2, for example. And if both the column and the row must be fixed, you'd use $B$2 syntax.

How to look up values in Workbook2 using values from workbook1?

In workbook 1, I have a two columns of values. The first column is a part number, and the second column is the quantity. Starting from the top, I would like to look up the part number from workbook1 and see if it's in workbook2. If not, then go to the next part. If so, then get the quantity from workbook1 and post that quantity in workbook2.
I am new to Excel, I have some knowledge of writing macros, but I am definitely a beginner.
For the sake of an answer:
According to OP, this worked:-
=IFERROR(VLOOKUP(A13,[Book2.xlsx]Sheet1!$A$1:$D$17,4,FALSE),0)

How do I use Macros to copy select data from one worksheet to another on Excel?

I need to create a Macro on Excel to keep track of changing contracts. There's already an existing macro that updates the contract data so I need to create another macro...
There are two worksheets. On the first worksheet is a bunch of data with each row representing one contract. There are several categories (Contract #, Date, Price, etc.).
I need to write a Macro that finds only certain contracts fitting specific criteria (like, contacts at a specific date or a certain price), copies and pastes them into the second worksheet.
What I've done so far:
I've figured out a bit of a convoluted way of doing it using IF and OR functions. So using OR I specify the criteria and IF to basically find the corresponding data if things are TRUE.
When things are false, a 0 is entered. The problem is I have tons of rows of zeroes---rows/contracts that didn't fit the criteria. When I try to use the find command (CTRL+F) to find, highlight, and properly delete (with rows shifted up) all the zeroes, Macro doesn't record it and I'm not sure how to write it in the code.
Any insight would help!
Just change your formula to:
=IF(OR(TermSheet!$E40=41220,TermSheet!$M40="bpxx"),TermSheet!E40,"")

Resources