Latex sorting bibliography - conditional-statements

I have a piece of code that sort my bibliography by date and type from a .bib file. It works just fine however i am asked to provide my bibliography from a starting year say 1996 i.e. skipping everything before.any help on what to amend to add this condition? thanks
for the .bib file please save in a file the following test found online, this is an example of database to be sorted:
%%%%%%%%%%% mybib.bib %%%%%%%%%%%%%%%%%%%
#BOOK{HK,
AUTHOR={H. Kopka and P. W. Daly},
TITLE={A Guide to LaTeX},
PUBLISHER={Addison-Wesley},
ADDRESS={Reading, MA},
YEAR=1999.
}
#BOOK{MG,
AUTHOR={M. Goossens and F. Mittelbach and A. Samarin},
TITLE={A LaTeX Companion},
PUBLISHER={Addison-Wesley},
ADDRESS={Reading, MA},
YEAR=1994.
}
#ARTICLE{Pan,
AUTHOR={D. Pan},
TITLE={A Tutorial on MPEG/Audio Compression},
JOURNAL={IEEE Multimedia},
YEAR={1995},
VOLUME= {2} ,
PAGES={60-74},
MONTH={Summer}.
}
#INPROCEEDINGS{Boney96,
AUTHOR={L. Boney and A. H. Tewfik and K. N. Hamdy},
TITLE={Digital Watermarks for Audio Signals},
booktitle={Proceedings of the Third IEEE International Conference on
Multimedia},
PAGES={473-480},
MONTH={June},
YEAR={1996}.
}
%%%%%%%%%%%%% end %%%%%%%%%%%%%%%%%%%%%
\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[backend=biber,sorting=ddatent,style=phys, defernumbers=true, natbib=true, isbn=true]{biblatex}
%sorting by date
\DeclareSortingScheme{ddatent}{
\sort{
\field{presort}
}
\sort[final]{
\field{sortkey}
}
\sort[direction=descending]{
\field[strside=left,strwidth=4]{sortyear}
\field[strside=left,strwidth=4]{year}
\literal{9999}
}
\sort[direction=descending]{
\field[padside=left,padwidth=2,padchar=0]{month}
\literal{00}
}
\sort[direction=descending]{
\field[padside=left,padwidth=2,padchar=0]{day}
\literal{00}
}
\sort[direction=descending]{
\field[padside=left,padwidth=4,padchar=0]{volume}
\literal{9999}
}
\sort{
\name{sortname}
\name{author}
\name{editor}
\name{translator}
\field{sorttitle}
\field{title}
}
\sort{
\field{sorttitle}
\field{title}
}
}
\addbibresource{mybib.bib}
\begin{document}
\printbibliography[heading=none,type=book]
\printbibliography[heading=none,type=article]
\end{document} `

You mustn't use . at the end of your bib entries.
Back to your actual question: you can define bibcheck:
\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[backend=biber,sorting=ddatent,style=phys, defernumbers=true, natbib=true, isbn=true]{biblatex}
%sorting by date
\DeclareSortingScheme{ddatent}{
\sort{
\field{presort}
}
\sort[final]{
\field{sortkey}
}
\sort[direction=descending]{
\field[strside=left,strwidth=4]{sortyear}
\field[strside=left,strwidth=4]{year}
\literal{9999}
}
\sort[direction=descending]{
\field[padside=left,padwidth=2,padchar=0]{month}
\literal{00}
}
\sort[direction=descending]{
\field[padside=left,padwidth=2,padchar=0]{day}
\literal{00}
}
\sort[direction=descending]{
\field[padside=left,padwidth=4,padchar=0]{volume}
\literal{9999}
}
\sort{
\name{sortname}
\name{author}
\name{editor}
\name{translator}
\field{sorttitle}
\field{title}
}
\sort{
\field{sorttitle}
\field{title}
}
}
\begin{filecontents*}[overwrite]{\jobname.bib}
%%%%%%%%%%% mybib.bib %%%%%%%%%%%%%%%%%%%
#BOOK{HK,
AUTHOR={H. Kopka and P. W. Daly},
TITLE={A Guide to LaTeX},
PUBLISHER={Addison-Wesley},
ADDRESS={Reading, MA},
YEAR=1999,
}
#BOOK{MG,
AUTHOR={M. Goossens and F. Mittelbach and A. Samarin},
TITLE={A LaTeX Companion},
PUBLISHER={Addison-Wesley},
ADDRESS={Reading, MA},
YEAR=1994,
}
#ARTICLE{Pan,
AUTHOR={D. Pan},
TITLE={A Tutorial on MPEG/Audio Compression},
JOURNAL={IEEE Multimedia},
YEAR={1995},
VOLUME= {2} ,
PAGES={60-74},
MONTH={Summer},
}
#INPROCEEDINGS{Boney96,
AUTHOR={L. Boney and A. H. Tewfik and K. N. Hamdy},
TITLE={Digital Watermarks for Audio Signals},
booktitle={Proceedings of the Third IEEE International Conference on
Multimedia},
PAGES={473-480},
MONTH={June},
YEAR={1996},
}
%%%%%%%%%%%%% end %%%%%%%%%%%%%%%%%%%%%
\end{filecontents*}
\addbibresource{\jobname.bib}
\defbibcheck{recent}{%
\iffieldint{year}
{\ifnumless{\thefield{year}}{1996}
{\skipentry}
{}}
{\skipentry}}
\begin{document}
\nocite{*}
\printbibliography[heading=none,type=book,check=recent]
\printbibliography[heading=none,type=article,check=recent]
\end{document} `

Related

Latex printing Listings in black/white only, although the rest is printed in color?

I'm currently having trouble printing my generated PDF of a latex document. Although printing the whole document in color just fine, for some reason all my listings are printed in black and white only. In the PDF itself the listings are displayed in color, just as expected. Is this a normal latex behavior or am I doing something wrong? I'm using the regular listing package with the following defined style. Minimum working example:
\documentclass[ twoside,openright,numbers=noenddot,%
toc=bibliography,toc=listof,%
footinclude=false,headinclude=false,cleardoublepage=empty,%
BCOR=5mm,paper=a4,fontsize=11pt,%DIV=14,%
ngerman%
]{scrreprt}
\RequirePackage[utf8]{inputenc}
\DeclareUnicodeCharacter{00A0}{~}
\RequirePackage[T1]{fontenc}
\newcommand{\currentVersion}{Version 2.1\xspace}
\newcounter{dummy}
\PassOptionsToPackage{ngerman}{babel}
\RequirePackage{babel}
\RequirePackage{csquotes}
\renewcaptionname{ngerman}{\listfigurename}{Abbildungen}
\renewcaptionname{ngerman}{\listtablename}{Tabellen}
\PassOptionsToPackage{fleqn}{amsmath}
\RequirePackage{amsmath}
\usepackage{geometry}
\geometry{a4paper,left=25mm,right=35mm,top=25mm,bottom=30mm}
\PassOptionsToPackage{dvipsnames}{xcolor}
\RequirePackage{xcolor}
\definecolor{ingwi}{cmyk}{.9,0,0,0}
\usepackage{textcomp}
\usepackage{scrhack}
\usepackage{xspace}
\usepackage{mparhack}
\PassOptionsToPackage{printonlyused}{acronym}
\usepackage{acronym}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage[shadow]{todonotes}
\newcommand{\todox}[1]{\todo[inline, size=\small]{#1}}
\newcounter{todocounter}
\renewcommand{\todox}[2][]{\stepcounter{todocounter}\todo[inline, size=\small,caption={\thetodocounter: #2}, #1]{\renewcommand{\baselinestretch}{0.5}\selectfont\thetodocounter: #2\par}}
\usepackage{blindtext}
\counterwithout{footnote}{chapter}
\usepackage{tabularx}
\setlength{\extrarowheight}{3pt}
\usepackage{caption}
\captionsetup{format=plain,indention=1em,font=small}
\usepackage{subfig}
\usepackage{wrapfig}
\usepackage{listings}
\lstset{emph={trueIndex,root},emphstyle=\color{BlueViolet}}%\underbar} % for special keywords
\lstset{language=[LaTeX]Tex,%C++,
keywordstyle=\color{RoyalBlue},%\bfseries,
basicstyle=\small\ttfamily,
%identifierstyle=\color{NavyBlue},
commentstyle=\color{Green}\ttfamily,
stringstyle=\rmfamily,
numbers=none,%left,%
numberstyle=\scriptsize,%\tiny
stepnumber=5,
numbersep=8pt,
showstringspaces=false,
breaklines=true,
% frameround=ftff,
frame=single,
texcl=true,
belowcaptionskip=.75\baselineskip
%frame=L
}
\lstdefinestyle{Java}{
belowcaptionskip=1\baselineskip,
breaklines=true,
xleftmargin=\parindent,
language=Java,
texcl=true,
numbers=left,
numberstyle=\tiny,
stepnumber=1,
numbersep=8pt,
showstringspaces=false,
basicstyle=\footnotesize\ttfamily,
keywordstyle=\bfseries\color{blue},
commentstyle=\itshape\color{black!50!white},
morecomment=[s][\color{white}]{---}{+++},
morecomment=[s][\color{orange!90!black}]{#}{\ },
identifierstyle=\color{black},
stringstyle=\color{green!60!black}}
\lstdefinestyle{Xml}{
belowcaptionskip=1\baselineskip,
breaklines=true,
xleftmargin=\parindent,
language=Java,
texcl=true,
numbers=left,
numberstyle=\tiny,
stepnumber=1,
numbersep=8pt,
showstringspaces=false,
basicstyle=\footnotesize\ttfamily,
identifierstyle=\bfseries\color{black},
commentstyle=\itshape\color{black!50!white},
stringstyle=\color{green!60!black}}
\PassOptionsToPackage{pdftex,hyperfootnotes=false,pdfpagelabels}{hyperref}
\usepackage{hyperref}
\pdfcompresslevel=9
\pdfadjustspacing=1
\PassOptionsToPackage{pdftex}{graphicx}
\usepackage{graphicx}
\hypersetup{%
%draft, % = no hyperlinking at all (useful in b/w printouts)
pdfstartpage=1, pdfstartview=Fit,%
colorlinks=true, linktocpage=true,
%urlcolor=Black, linkcolor=Black, citecolor=Black, %pagecolor=Black,%
%urlcolor=brown, linkcolor=RoyalBlue, citecolor=green, %pagecolor=RoyalBlue,%
% uncomment the following line if you want to have black links (e.g., for printing)
colorlinks=false, pdfborder={0 0 0},
breaklinks=true, pdfpagemode=UseNone, pageanchor=true, pdfpagemode=UseOutlines,%
plainpages=false, bookmarksnumbered, bookmarksopen=true, bookmarksopenlevel=1,%
hypertexnames=true, pdfhighlight=/O,%nesting=true,%frenchlinks,%
pdftitle={test},%
pdfauthor={\textcopyright\ test, test},%
pdfsubject={},%
pdfkeywords={},%
pdfcreator={pdfLaTeX},%
pdfproducer={LaTeX with hyperref}%
}
\makeatletter
\#ifpackageloaded{babel}%
{%
\addto\extrasamerican{%
\renewcommand*{\figureautorefname}{Figure}%
\renewcommand*{\tableautorefname}{Table}%
\renewcommand*{\partautorefname}{Part}%
\renewcommand*{\chapterautorefname}{Chapter}%
\renewcommand*{\sectionautorefname}{Section}%
\renewcommand*{\subsectionautorefname}{Section}%
\renewcommand*{\subsubsectionautorefname}{Section}%
}%
\addto\extrasngerman{%
\renewcommand*{\chapterautorefname}{Kapitel}%
\renewcommand*{\sectionautorefname}{Abschnitt}%
\renewcommand*{\subsectionautorefname}{Abschnitt}%
\renewcommand*{\subsubsectionautorefname}{Abschnitt}%
\renewcommand*{\paragraphautorefname}{Absatz}%
\renewcommand*{\subparagraphautorefname}{Absatz}%
\renewcommand*{\footnoteautorefname}{Fu\"snote}%
\renewcommand*{\FancyVerbLineautorefname}{Zeile}%
\renewcommand*{\theoremautorefname}{Theorem}%
\renewcommand*{\appendixautorefname}{Anhang}%
\renewcommand*{\equationautorefname}{Gleichung}%
\renewcommand*{\itemautorefname}{Punkt}%
}
\providecommand{\subfigureautorefname}{\figureautorefname}%
}{\relax}
\makeatother
\PassOptionsToPackage{l2tabu,orthodox,abort}{nag}
\usepackage{nag}
\usepackage{enumitem}
\setdescription{font=\normalfont\bfseries}
\usepackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true,factor=1100,stretch=10,shrink=10]{microtype}
\usepackage{mathpazo}
\setkomafont{disposition}{\bfseries}
\usepackage{adjustbox}
\usepackage{tabularx}
\usepackage{pifont}
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\newcommand{\code}[1]{\texttt{\em{#1}}}
\begin{document}
\frenchspacing
\raggedbottom
\selectlanguage{ngerman}
\pagenumbering{roman}
\pagestyle{plain}
\cleardoublepage
\pagenumbering{arabic}
\pagestyle{headings}
\begin{minipage}[chbt]{0.95\textwidth}
\begin{lstlisting}[caption=test,captionpos=b,label={lst:example_facade},style=Java]
public class ExampleFacade implements CrudFacade<ExampleEntity> {
#Override
public ExampleEntity getSpecificEntity(String id) throws NoSuchDataSetException {
// retrieve specific entity from database
// ...
}
}
\end{lstlisting}
\end{minipage}
\begin{figure}[hbt]
\centering
\includegraphics[width=0.6\textwidth]{insert your picture here}
\caption{test}
\label{fig:lifecycle}
\end{figure}
\end{document}
Download my PDF: https://www.file-upload.net/download-14777480/test.pdf.html
Edit: It seems as though this is only a problem with my particular printer for some reason I can't explain at all. When using the printer of a friend it works just fine, even with the original PDF, not just the working example. I'm using the Brother DCP-L3550CDW.

Buddypress - Limit Blog Excerpt on Activity Stream

I'm using the following code to limit the number of words that appear on my blog pages.
function custom_excerpt_length( $length ) { return 32; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
I need to limit the number of words that appear on the BuddyPress Activity Stream when someone creates a blog post. Currently when someone creates a new blog post, the excerpt appears on the Activity Stream with about 50+ words. I need to limit this to around 32 words.
Does anyone know how to accomplish this?
Thx
This is what I'm using. The first part limits the text, the second part ensures the thumbnail is present. Thank you shanebp for pointing me in the right direction.
function 5_activity_content_body( $content, $activity ) {
$content_length = 42;
if ( 'new_blog_post' == $activity->type ) {
$images = extractImageFromContent($content);
$_content = (strlen($content) > $content_length) ? substr($content, 0, $content_length).'...' : $content;
if(!empty($images)) {
$_content .= implode("", $images);
}
return $_content;
}
return $content;}
add_filter( 'bp_get_activity_content_body', '5_activity_content_body', 10, 2 );
This brings the thumbnail back.
function extractImageFromContent($html) {
preg_match_all('/<img.*?src=[\'"](.*?)[\'"].*?>/i', $html, $matches);
return ($matches[0]) ? $matches[0] : array(); }

How to override the NQPMatch.Str function

... Or how to change $<sigil>.Str value from token sigil { ... } idependently from the matched text. Yes I'm asking how to cheat grammars above (i.e. calling) me.
I am trying to write a Slang for Raku without sigil.
So I want the nogil token, matching anything <?> to return NqpMatch that stringifies: $<sigil>.Str to '$'.
Currently, my token sigil look like that
token sigil {
| <[$#%&]>
| <nogil> { say "Nogil returned: ", lk($/, 'nogil').Str; # Here It should print "$"
}
}
token nogil-proxy {
| '€'
| <?>
{log "No sigil:", get-stack; }
}
And the method with that should return a NQPMatch with method Str overwritten
method nogil {
my $cursor := self.nogil-proxy;
# .. This si where Nqp expertise would be nice
say "string is:", $cursor.Str; # here also it should print "$"
return $cursor;
}
Failed try:
$cursor.^cache_add('Str', sub { return '$'; } );
$cursor.^publish_method_cache;
for $cursor.^attributes { .name.say };
for $cursor.^methods { .name.say };
say $cursor.WHAT.Str;
nqp::setmethcacheauth($cursor, 0);
Currently, most of my tests work but I have problems in declarations without my (with no strict) like my-var = 42; because they are considered as method call.
#Arne-Sommer already made a post and an article. This is closely related. But this questions aims:
How can we customize the return value of a compile-time token and not how to declare it.
Intro: The answer, pointed by #JonathanWorthington:
Brief: Use the mixin meta function. (And NOT the but requiring compose method.)
Demo:
Create a NQPMatch object by retrieving another token: here the token sigil-my called by self.sigil-my.
Use ^mixin with a role
method sigil { return self.sigil-my.^mixin(Nogil::StrGil); }
Context: full reproducible code:
So you can see what type are sigil-my and Nogil::StrGil. But I told you: token (more than method) and role (uninstantiable classes).
role Nogil::StrGil {
method Str() {
return sigilize(callsame);
}
}
sub EXPORT(|) {
# Save: main raku grammar
my $main-grammar = $*LANG.slang_grammar('MAIN');
my $main-actions = $*LANG.slang_actions('MAIN');
role Nogil::NogilGrammar {
method sigil {
return self.sigil-my.^mixin(Nogil::StrGil);
}
}
token sigil-my { | <[$#%&]> | <?> }
# Mix
my $grammar = $main-grammar.^mixin(Nogil::NogilGrammar);
my $actions = $main-actions.^mixin(Nogil::NogilActions);
$*LANG.define_slang('MAIN', $grammar, $actions);
# Return empty hash -> specify that we’re not exporting anything extra
return {};
}
Note: This opens the door to mush more problems (also pointed by jnthn question comments) -> -0fun !

Getting all bids from each Header bidding partners

We are implementing some header bidding partners on our wrapper using prebid. Is it possible to get all bids from each ssp.
Any help appreciated.
If you’re asking about demand, this is dependent on each SSP. For example there may be a segment pixel or placement in one SSP that will always give you a $10 bid, but that wouldnt apply to the other SSPs.
If your asking about getting data on all the bids, you may want to check out pbjs.getBidResponses() which returns an object with the ad units and bids
Heres a sample response from pbjs.getBidResponses() which can then be used however you'd need that data:
{
"div-id-one": {
"bids": [
{
"bidderCode": "appnexus",
"width": 970,
"height": 250,
"statusMessage": "Bid available",
"adId": "1293a95bb3e9615",
"mediaType": "banner",
"creative_id": 77765220,
"cpm": 0.7826,
"adUrl": "https://...",
"requestId": "57f961f3-a32b-45df-a180-9d5e53fb9070",
"responseTimestamp": 1513707536256,
"requestTimestamp": 1513707535321,
"bidder": "appnexus",
"adUnitCode": "div-id-one",
"timeToRespond": 935,
"pbLg": "0.50",
"pbMg": "0.70",
"pbHg": "0.78",
"pbAg": "0.75",
"pbDg": "0.78",
"pbCg": "0.78",
"size": "970x250",
"adserverTargeting": {
"hb_bidder": "appnexus",
"hb_adid": "1293a95bb3e9615",
"hb_pb": "0.78",
"hb_size": "970x250"
}
}
]
},
"div-id-two": {
"bids": []
}
}
Theres also a great example on prebid.org on how to output this to console.table that could be helpful as well:
var responses = pbjs.getBidResponses();
var output = [];
for (var adunit in responses) {
if (responses.hasOwnProperty(adunit)) {
var bids = responses[adunit].bids;
for (var i = 0; i < bids.length; i++) {
var b = bids[i];
output.push({
'adunit': adunit, 'adId': b.adId, 'bidder': b.bidder,
'time': b.timeToRespond, 'cpm': b.cpm, 'msg': b.statusMessage
});
}
}
}
if (output.length) {
if (console.table) {
console.table(output);
} else {
for (var j = 0; j < output.length; j++) {
console.log(output[j]);
}
}
} else {
console.warn('NO prebid responses');
}
There is also a chrome extensions called Prebid helper that do the same as console snippet but with less clicks.
However that is useful for initial setup debug. If you need to gather aggregated data on all demand partners - bids, timeouts, wins etc. You will need to run third party wrapper analytics or use analytics adapter. It's not free but it usually is priced depending on your load on the analytics server. For example https://headbidder.net/pricing
Try out the Chrome Extension called Adwizard. It's been built to debug prebid setups. Shows you all networks and bids per adunit. CPM and Size included.
https://chrome.google.com/webstore/detail/adwizard/kndnhcfdajkaickocacghchhpieogbjh/?ref=stackoverflow

Plot multiple y-axes in Plotly

I have the following code for my layout:
var layout = {
title:"Energy usage of green electrical appliances",
plot_bgcolor:"#000",
paper_bgcolor:"#000",
showlegend:false,
margin:"{l: 40, b: 40, r: 80, t: 40,}",
xaxis:{
title:"Date/Time",
autoscale:"true",
rangeselector: {
bgcolor:"#555",
},
yaxis:{
title:"Price",
autoscale:"true",
overlaying:"y2",
side:"left",
},
yaxis2: {
title:"Electricity Used",
autoscale:"true",
side:"right"
},
yaxis3:{
title:"AiJ/day",
autoscale:"true",
side:right
}
}
and the following code for my data:
var tracePrice= {name:"Price",type:"scatter",x:output[0]["datetime"],y:output[0]["price"],line:{color:"orange",width:2},};
var traceElecUsed= {name:"Elec",type:"bar",x:output[0]["datetime"],y:output[0]["Elec"],line:{color:"cyan",width:2},};
var traceAiJ= {name:"aij",type:"scatter",x:output[0]["datetime"],y:output[1]["aijpercent"],yaxis:"y2",marker:{color:"#fff"},line:{color:"#555",width:1}};
return resolve([tracePrice,traceElecUsed,traceAiJ]);
The thing is, everything works fine until I plot traceElecUsed. The units it usesare in the thousands, whereas price is often under £5 and AiJ is a percentage of 0-100%. I don't know if this is the root of the issue. If I remove it everything works fine.
The stackoverflow curse has got me again; I struggle for hours with something then once I've posted it the answer appears.
For those of you in the future that need this info, it relies on 'overlaying'
yaxis3: {
title:"Aij",
autoscale:"true",
overlaying:"y2",
side:"right"
}