Multiple LaTeX bibliographies each in descending chronological order with reverse numbering - latex

I'm working on my CV in moderncv latex document, and my plan is to have separate lists for
publications (type=article),
data sets (type=misc), and
presentations (type=inproceedings)
I'm looking for someone wiser to tell me, if it is indeed possible to have
three bibliographies in a single document,
each of them in descending chronological order (newest first), and
with reverse numbering?
i.e.
Section: Publications
[9.] Publication (newest)
[8.] Publication (second newest)
...
[1.] Publication (oldest)
Section: Data sets
[5.] Data set (newest)
[4.] Data set (second newest)
...
[1.] Data set (oldest)
Section: Presentations
[11.] Presentation (newest)
[10.] Presentation (second newest)
...
[1.] Presentation (oldest)
So far I have managed to make one single bibliography in descending chronological order with reverse numbering for my publications (thanks internet!). If I add other entries in the same bib file and separate them by keyword or type, the numbering of the separate lists is screwed up. In that case all entries are first put in descending chronological order and assigned numbers, but only then split into separate lists. Therefore the numbering in each list is not consecutive anymore.
Here's what I used in the preamble:
\usepackage[backend=bibtex,style=numeric,sorting=ydnt,url=false,doi=true,maxnames=120]{biblatex}
% Count total number of entries in each refsection
\AtDataInput{%
\csnumgdef{entrycount:\therefsection}{%
\csuse{entrycount:\therefsection}+1}}
% Print the labelnumber as the total number of entries in the
% current refsection, minus the actual labelnumber, plus one
\DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}}
\newrobustcmd*{\mkbibdesc}[1]{%
\number\numexpr\csuse{entrycount:\therefsection}+1-#1\relax}
\addbibresource{bibliography.bib}
In the main document itself, I use
\nocite{*}
\printbibheading[title={Publications}]
\printbibliography[title={Peer-reviewed},heading=subbibliography, type=article]
\printbibliography[title={Data},heading=subbibliography, type=misc]
\section{Presentations}
\printbibliography[heading=none, type=inproceedings]
Stack Overflow, I'm counting on you!

Related

How can I find the first instance (searching up) of a value in a column?

Picture linked below as this is a bit tangled:
I am working with a data set that has "nested" values. There are three different types of entries: categories, then subcategories that are nested under the categories, then individual items that are nested under the subcategories (picture linked below). The entries are matched up using a filter system. Column A has the entry type, column B has the actual value, column C has the filter. The filter is always the value of entry you are nesting under. So, for a subcategory entry, Column A= "Subcategory", Column B= [name of subcategory] Column C = Column B of the category type entry above (the name of category it belongs to).
I need a way to automatically fill in the filters.
The way I am thinking I could do this is to search Column A (moving up) for the first instance of the entry type I need, and then return the value of the Column B cell in that row. Is this possible?
Given your exact data above (looking only at A14:C), delete everything from C14:C (including the header) and place the following formula in C14:
=ArrayFormula({"FILTER"; IF((A15:A="") + (A15:A="Category"),, IF(A15:A="Subcategory", VLOOKUP(ROW(A15:A), FILTER({ROW(A15:A), B15:B}, A15:A="Category"), 2, TRUE), VLOOKUP(ROW(A15:A), FILTER({ROW(A15:A), B15:B}, A15:A="Subcategory"), 2, TRUE)))})
This will create the title (which you can edit within the formula itself as you like) and all results for non-null rows thereafter.
You'll need to adjust the 15 in ranges to whatever the starting row of your non-header data actually is in your sheet.

Calculating self citation counts in DBLP using neo4j

I have imported the DBLP database with referenced publications from Crossref API into neo4j.
The goal is to calculate a self-citation-quotient for each author in the database.
The way I´d like to calculate this quotient is the following:
find authors that have written publications referencing another publication written by the same author
for each of these publications count the referenced publications written by the same author
divide amount of self references by the amount of all references
set this number as a parameter scq(self citation quotient) for the publication
sum all values of scq and divide them by the total amount of publications written by the author
set this value as a property scq for the Author
As an example I have the following sub-graph for the author "Danielle S. Bassett":
From the graph you can see that she has 2 publications that contain self-references.
In Words:
Danielle wrote Publication 1, 2, 3, 4
Publication 1 references publication 2
Publication 3 references publication 4
My attempt was to use the following cypher query:
match (a:Author{name:"Danielle S. Bassett"})-[:WROTE]->(p1:Publication)-[r:REFERENCES]->(p2:Publication)<-[:WROTE]-(a)
with count(p2) as ssc_per_publ,
count(p1) as main_publ_count,
collect(p2) as self_citations,
collect(p1) as main_publ,
collect(r) as refs,
a as author
return author, main_publ, ssc_per_publ, self_citations, main_publ_count, refs
The result of this query as a table looks like this:
As you can see from the table the main_publ_count is calculated correctly since there are 2 publications she has written that contain self references but the ssc_per_publ (self citation count per publication) is wrong because it counted ALL self references. But I need the count of self references for EACH PUBLICATION.
Calculating the quotients will not be the problem but getting the right values from neo4j is.
I hope I´ve expressed myself clearly enough for you to understand the issue.
Maybe someone of you knows a way of getting this right. Thanks!
Your WITH clause is using author as the sole aggregation function "grouping key", since it is the only term in that clause not using an aggregation function. So, all the aggregation functions in that clause are aggregating over just that one term.
To get a "self citation count" per publication (by that author), you'd have to do something like the following (for simplicity, this query ignores all the other counts and collections). author and publ together form the "grouping key" in this query.
MATCH (author:Author{name:"Danielle S. Bassett"})-[:WROTE]->
(publ:Publication)-[r:REFERENCES]->(p2:Publication)<-[:WROTE]-(a)
RETURN author, publ, COUNT(p2) as self_citation_count;
[Aside: your original query has other issues as well. For example, you should use COUNT(DISTINCT p1) as main_publ_count so that multiple self-citations to the same p1 instance will not inflate the count of "main" publications.]

Hmisc and LaTeX multicloumn

I am trying to create a multicolumn in a LaTeX table. It's easy to do this manually but I create these tabled from data frames generated fro many reports so doing it manually is time consuming. What I have is :
cat(cfrm, file="table2.tex") # this categotises the file
t2<-latex(tabl2, file="table2.tex", cellTexCmds = cellTex, rowname=NULL, colheads=c(paste("Recent Average Catch (",minyear," - ",maxyear,")",sep=""), "Skipjack", "Yellowfin","Bigeye","SP Albacore"),
caption=paste("Key fishery statistics averaged from ",minyear," to C$_{latest}$ for each of the four main target tunas. Where C$_{latest}$ is the last year in each species assessment model. \\label{tab2}", sep=""), caption.lot=NULL, caption.loc='top',
longtable=TRUE, collabel.just=c("c","c","c","c","c"), size="small",
col.just=c("l","c","c","c","c"), colnamesTexCmd=c("apple") , append=TRUE)
which fives me the table attached:
What I would like to do is set the blue rows to be a multicolumn.

How do I parse a table into its meaningful chunks?

I need to extract a table of data on a collection of pages. I can already traverse the pages just fine.
How do I extract the table's data? I'm using Ruby and Nokogiri, but I would assume that this is a pretty general issue.
I underlined the desired data points in each row in the following image.
A sample of the html is: http://pastebin.com/YYFPbFLC
How would I parse this table into a hash via Nokogiri into the meaningful chunks?
The table's xpath is:
/html/body/table/tbody/tr/td[2]/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr/td/table/tbody/tr/td[2]/table
The table has a variable number of rows of data and formatting rows. I only want to collect the rows with meaningful data, but I don't readily see a way to distinguish this via an XPath except the second column will reliably have "keyword" in it. Each of these rows have an XPath of:
1st meaningful row is: /html/body/table/tbody/tr/td[2]/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr/td/table/tbody/tr/td[2]/table/tbody/tr[2]
...
Last meaningful row: /html/body/table/tbody/tr/td[2]/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr/td/table/tbody/tr/td[2]/table/tbody/tr[N]
The first meaningful column that needs to match text content on the "keyword" is:
/html/body/table/tbody/tr/td[2]/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr/td/table/tbody/tr/td[2]/table/tbody/tr[2]/td[2]
The last column of this first row of data would be:
/html/body/table/tbody/tr/td[2]/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr/td/table/tbody/tr/td[2]/table/tbody/tr[2]/td[6]
Each row is a record and has a timestamp with this column/td being the time in the timestamp; The year, month and day are all in their own variables and can be appended for a full timestamp:
/html/body/table/tbody/tr/td[2]/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr/td/table/tbody/tr/td[2]/table/tbody/tr[2]/td[5]
The first rule of XPath is: never use the autogenerated XPath from Firebug or other browser tool. This creates brittle XPath that treats all page elements as equally important and required, even parts you don't care about. For example, if a notice went up at the top of the page and it happened to be in a table, it could throw off your parsing.
Instead, think about how a human would identify it. In this case, you want "the first table under the heading with the word 'today' in it". Here's the XPath for that:
//table[preceding-sibling::h2[contains(text(), "today")]][1]
This says take the tables that have a preceding h2 (in other words, that follow the h2), where the h2 contains the word "today". Then take the first such table.
Then you need to identify the rows you are interested in. Note that some rows are just dividers containing a single td, so you want to make sure you only parse the rows that have multiple td tags. In XPath, that is:
//tr[td[2]]
Then you just grab the content of all the columns. In the first one you can remove everything before the words "of magnitude" to get just the value. Putting it all together:
doc = Nokogiri::HTML.parse(html)
events = []
doc.xpath('//table[preceding-sibling::h2[contains(text(), "today")]][1]//tr[td[2]]').each do |row|
cols = row.search('td/text()').map(&:to_s)
events << {
:magnitude => cols[0].gsub(/^.*of magnitude /,''),
:temp_area => cols[1],
:time_start => cols[2],
:time_middle => cols[3],
:time_end => cols[4]
}
end
The output is:
[
{:magnitude=>"F1.7",
:temp_area=>"0",
:time_start=>"01:11:00",
:time_middle=>"01:24:00",
:time_end=>"01:32:00"},
{:magnitude=>"F3.1",
:temp_area=>"0",
:time_start=>"04:01:00",
:time_middle=>"04:10:00",
:time_end=>"04:26:00"},
{:magnitude=>"F3.5",
:temp_area=>"134F55",
:time_start=>"06:24:00",
:time_middle=>"06:42:00",
:time_end=>"06:53:00"},
{:magnitude=>"F1.4",
:temp_area=>"0",
:time_start=>"11:58:00",
:time_middle=>"12:06:00",
:time_end=>"12:16:00"},
{:magnitude=>"F1.0",
:temp_area=>"0",
:time_start=>"13:02:00",
:time_middle=>"13:05:00",
:time_end=>"13:09:00"},
{:magnitude=>"D53.7",
:temp_area=>"134F55",
:time_start=>"17:37:00",
:time_middle=>"18:37:00",
:time_end=>"18:56:00"}
]

include the word "table" in List of Tables, "Appendix" in Table of Contents, etc

I need to include the word "Table" at the beginning of each line in my List of Tables. That is, instead of:
LIST OF TABLES
1 The first table ........... 10
2 The second table ........... 20
I need it to say:
LIST OF TABLES
Table 1 The first table ........... 10
Table 2 The second table ........... 20
Yes, I know that's ugly, but those are the rules.
I also need the Table of contents to say:
Table of Contents
1 The first Chapter ...... 1
Appendices
Appendix A The A appendix ........ 10
Any idea how to do this in a simple and consistent manner?
To answer your three questions:
1: Table prefix in the list of tables put the following in your preamble:
\usepackage{tocloft}
\newlength\tablelen
\settowidth\tablelen{Table}
\addtolength\cfttabnumwidth{\tablelen}
\renewcommand\cfttabpresnum{Table }
2: To have "Appendices" appear in your table of contents put the following just after your call to \appendix:
\addcontentsline{toc}{chapter}{Appendices}
3: To have "Appendix" as a prefix for each appendix in the table of contents, see:
http://for.mat.bham.ac.uk/pgweb/thesisfiles/bhamthesisman.pdf
http://for.mat.bham.ac.uk/pgweb/thesisfiles/bhamthesis.dtx
in particular, search for his \renewcommand{\appendix} in which add to contents is changed.
The easier way is to replace the word \listoftables with
{%
\let\oldnumberline\numberline%
\renewcommand{\numberline}{\tablename~\oldnumberline}%
\listoftables%
}

Resources