Grayed listing environment with LaTeX - latex

Form this LaTeX-workshop, I found I could make this listing style.
http://img441.imageshack.us/img441/2739/screenshot20100717at112.png
by defining a new environment.
\definecolor{mittelgrau}{gray}{0.85}%
\lstdefinestyle{StyleCommand}{%
style=StyleListingBasic, backgroundcolor=\color{mittelgrau}, prebreak=\mbox{\textbackslash{}}%
}
\lstnewenvironment{bevel}[1][1] {\lstset{style=StyleCommand,linewidth=#1\linewidth}} {}%
Running the code, I get this error message.
ERROR: Package Listings Error: Couldn't load requested style.
What might be wrong?

I missed the \lstdefinestyle, and after some modification, I could make it work.
\documentclass{article}
\usepackage{color} % Farben
\usepackage{listings} % für Listings
% Listingdefinitionen
\lstdefinestyle{StyleListingBasic}{%
basicstyle=\ttfamily, % Schriftstil
frame=single, % einfacher Rahmen
framesep=1pt, % Abstand des Rahmens
framerule=0.8pt, % Linienstaerke des Rahmens
rulecolor=\color{mittelgrau}, % Farbe der Rahmenlinie
breaklines=true, % automatischen Umbruch aktivieren
breakindent=0pt % Einrueckung nach Umbruch
}
\definecolor{mittelgrau}{gray}{0.85}%
\lstdefinestyle{StyleCommand}{%
style=StyleListingBasic, backgroundcolor=\color{mittelgrau}, prebreak=\mbox{\textbackslash{}}%
}
\lstnewenvironment{Befehl}[1][1] {\lstset{style=StyleCommand,linewidth=#1\linewidth}} {}%
\begin{document}
\begin{Befehl}
./robots-gui-helper
\end{Befehl}%
\end{document}

Related

Adding a new line before lstnewenvironment

I'm using lstnewenvironment from the listings package to create new code blocks.
Using an example from its manual:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\lstnewenvironment{pascal}
{\hfill pascal \lstset{language=pascal}}
{}
\begin{document}
some text before code block
\begin{pascal}
for i := maxint to 0 do
begin
{ do nothing}
end;
\end{pascal}
\end{document}
This generates a pascal code block like:
enter image description here
Now I want to add some text as 'tag' above the code line (at the end of that line) like:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\lstnewenvironment{pascal}
{\hfill{\tiny pascal} \lstset{language=pascal}}
{}
This generates:
enter image description here
The tag text is at the same line with previous text, so I add \\ before the tag:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\lstnewenvironment{pascal}
{ \\ \hfill{\tiny pascal} \lstset{language=pascal}}
{}
And tried
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\lstnewenvironment{pascal}
{ \\ \hspace{\textwidth}{\tiny pascal} \lstset{language=pascal}}
{}
But both of the hfill and \hspace{\textwidth} don't work, the tag appears at the beginning of the line above:
enter image description here
The only way I can do is manually adding a blank line between the code block and previous text:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\lstnewenvironment{pascal}
{ \hfill{\tiny pascal} \lstset{language=pascal}}
{}
\begin{document}
some text before code block
\begin{pascal}
for i := maxint to 0 do
begin
{ do nothing}
end;
\end{pascal}
\end{document}
Output:
enter image description here
My question is how to modify the \lstnewenvironment settings so that it can automatically add a new line between the code block and the previous text, with a tag at the end of that new line?
see https://tex.stackexchange.com/a/625934/36296
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\lstnewenvironment{pascal}
{
\endgraf {\hfill \tiny pascal} \lstset{language=pascal}}
{}
\begin{document}
some text before code block
\begin{pascal}
for i := maxint to 0 do
begin
{ do nothing}
end;
\end{pascal}
some text before code block
\begin{pascal}
for i := maxint to 0 do
begin
{ do nothing}
end;
\end{pascal}
\end{document}

How to add corresponding author in acmart class

I want "Corresponding author" to appear only where Authors’ address are mentioned [bottom of page]. It should not appear at the start [as shown in highlighted image].
I dont want to use \thanks or footnotes. I try authornote at differnt places but it appears separately.
The MWE is as follows:
\documentclass[acmlarge, authorversion]{acmart}
\AtBeginDocument{%
\providecommand\BibTeX{{%
\normalfont B\kern-0.5em{\scshape i\kern-0.25em b}\kern-0.8em\TeX}}}
\acmJournal{CSUR}
\acmVolume{}
\acmNumber{}
\acmArticle{}
\acmMonth{3}
\begin{document}
\title{Title is ACM}
\author{First}
\affiliation{%
\institution{University}
\city{city}
\country{country}}
\email{author#author.com}
\author{A}
\affiliation{%
\institution{University}
\city{city}
\country{country}}
\email{author#author.com}
\author{B}
\affiliation{%
\institution{University}
\city{city}
\country{country}}
\email{author#author.com}
\author{C}
\affiliation{%
\institution{(corresponding author), University}
\city{city}
\country{country}
}
\email{author#author.com}
% \thanks{(corresponding author)}
% \authornote{(corresponding author)}
\renewcommand{\shortauthors}{author et al.}
\begin{abstract}
abstract here...
\end{abstract}
\begin{CCSXML}
<ccs2012>
<concept>
<concept_id>10002944.10011122.10002945</concept_id>
<concept_desc>General and reference~Surveys and overviews</concept_desc>
<concept_significance>500</concept_significance>
</concept>
<concept>
<concept_id>10002978.10003006.10003013</concept_id>
<concept_desc>Security and privacy~Distributed systems security</concept_desc>
<concept_significance>300</concept_significance>
</concept>
</ccs2012>
\end{CCSXML}
\ccsdesc[500]{General and reference~Surveys and overviews}
\ccsdesc[300]{Security and privacy~Distributed systems security}
\keywords{ABC, XYZ}
\maketitle
\end{document}
\endinput

Cite author and title for monographs

for a university paper I have to write an essay. The professor has percise instructions how to cite. For monograph books, he wants the author and the title in the footnotes.
I tried to use biblatex for this, but could not manage to get it to work
My minimal reproducible example is:
\documentclass{article}
\usepackage[utf8]{inputenc}
\title{test}
\usepackage[style=authoryear,maxcitenames=2,maxbibnames=99, uniquename=false]{biblatex}
\addbibresource{references.bib}
\setcounter{biburlnumpenalty}{100}
\setcounter{biburlucpenalty}{100}
\setcounter{biburllcpenalty}{100}
\DefineBibliographyStrings{ngerman}{
andothers = {{et\,al\adddot}},
}
\DeclareNameAlias{sortname}{family-given}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{title}{#1\isdot}
\renewbibmacro{in:}{%
\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
\begin{document}
\maketitle
\section{Introduction}
This is a minimal reproducible example. \footcite{adams1995hitchhiker}
\printbibliography
\end{document}
which outputs:
footnote image
Now i want to add the title of the book too (in this case The Hitchhiker's Guide to the Galaxy) in the footnote
Any idea how to implement this?
It sounds as if the authortitle style would be closer to your requirements:
\documentclass{article}
\usepackage[utf8]{inputenc}
\title{test}
\usepackage[style=authortitle,maxcitenames=2,maxbibnames=99, uniquename=false]{biblatex}
\begin{filecontents*}[overwrite]{\jobname.bib}
#book{knuth,
author = {Knuth, Donald E.},
title = {The {\TeX} book},
date = 1984,
maintitle = {Computers \& Typesetting},
volume = {A},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
langid = {english},
langidopts = {variant=american},
sortyear = {1984-1},
sorttitle = {Computers & Typesetting A},
indexsorttitle= {The TeXbook},
indextitle = {\protect\TeX book, The},
shorttitle = {\TeX book}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\setcounter{biburlnumpenalty}{100}
\setcounter{biburlucpenalty}{100}
\setcounter{biburllcpenalty}{100}
\DefineBibliographyStrings{ngerman}{
andothers = {{et\,al\adddot}},
}
\DeclareNameAlias{sortname}{family-given}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{title}{#1\isdot}
\renewbibmacro{in:}{%
\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
\begin{document}
\maketitle
\section{Introduction}
This is a minimal reproducible example. \footcite{knuth}
\printbibliography
\end{document}

convert bib file to \bibitem[\protect\citeauthoryear

I have a reference file (bib file) I want to convert it as
\bibitem[\protect\citeauthoryear{Allen C.W.}{1973}] {b1} Allen C.W., 1973,
Astrophysical quantities, ${3^{rd}}$ ed. (Athlone Press, London)
when I use
\nocite{*}
\bibliographystyle{apalike}
\bibliography{bibfile}
Output ppl file as
\bibitem[Allen, 1973]{allen1973astrophysical}
Allen, C.~W. (1973).
Combining natbib with the newapa style gives something similar:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
#BOOK{1973asqu.book.....A,
author = {{Allen}, C.~W.},
title = "{Astrophysical quantities}",
keywords = {ASTROPHYSICS, ASTRONOMICAL CONSTANTS, TABLES, HANDBOOKS},
booktitle = {London: University of London, Athlone Press, |c1973, 3rd ed.},
year = 1973,
adsurl = {https://ui.adsabs.harvard.edu/abs/1973asqu.book.....A},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}
\end{filecontents*}
\usepackage{natbib}
\begin{document}
\cite{1973asqu.book.....A}
\bibliographystyle{newapa}
\bibliography{\jobname}
\end{document}
Resulting .bbl file:
\begin{thebibliography}{}
\bibitem[\protect\citeauthoryear{{Allen}}{{Allen}}{1973}]{1973asqu.book.....A}
{Allen}, C.~W. (1973).
\newblock {\em {Astrophysical quantities}}.
\end{thebibliography}

Bibliography style and line breaks in Beamer-poster

I'm making a poster through beamer and found a problem with my bibliography style. I want my references to use the full horizontal space available in the poster, like:
(1) Authors. Title. Journal.
But instead of that, every reference get breaked in 3 lines as:
(1) Authors
Title
Journal
Example
Here's the bibliography code I've been using:
\begin{block}{References}
\small
\bibliographystyle{sbc}
\bibliography{referencias.bib}
\end{block}
The line breaks can be avoided by setting the bibliography templates like this:
\setbeamertemplate{bibliography entry article}{}
\setbeamertemplate{bibliography entry title}{}
\setbeamertemplate{bibliography entry location}{}
\setbeamertemplate{bibliography entry note}{}
MWE:
\documentclass{beamer}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
#book{knuth,
author = {Knuth, Donald E.},
title = {The {\TeX} book},
date = 1984,
maintitle = {Computers \& Typesetting},
volume = {A},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
langid = {english},
langidopts = {variant=american},
sortyear = {1984-1},
sorttitle = {Computers & Typesetting A},
indexsorttitle= {The TeXbook},
indextitle = {\protect\TeX book, The},
shorttitle = {\TeX book}
}
\end{filecontents*}
\setbeamertemplate{bibliography entry article}{}
\setbeamertemplate{bibliography entry title}{}
\setbeamertemplate{bibliography entry location}{}
\setbeamertemplate{bibliography entry note}{}
\begin{document}
\begin{frame}
\cite{knuth}
\begin{block}{References}
\small
\bibliographystyle{plain}
\bibliography{\jobname}
\end{block}
\end{frame}
\end{document}

Resources