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

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.

Related

Inline math font size and equations spacing in markdown to pdf conversion using pandoc

I'm using vim and markdown as an alternative to obsidian. I'm doing the conversion from markdown to pdf using pandoc and I would like to resemble as much as possible the pdf output of obsidian since I like how it looks.
In general I could make both pdf looks almost the same, but, I got two problems, the first is that the inline math font is too big, the second that the spacing before and after an equation is different.
Here are two screenshots, the first one being the pandoc output, the second the obsidian output.
To style the pdf I'm using a custom latex snippet which I include with pandoc -H style.tex ... during the pdf compilation, with this I was able to change the spacing between the text and the sections title as well as other things like page margins, etc. But I didn't find anything related to the math nor the equation for a template
I've also tried writing the equation as $\small \vec{E}$ but didn't work.
I think it has to be a way of changing the spacing from the latex template, I know that pandoc is using the unicode-math package to convert the latex equations but didn't find nothing related on how to change the spacing for the equations nor the font size.
EDIT: the style.tex file
% page setup
\usepackage[a4paper,
top=2cm,
bottom=1.75cm,
left=1.75cm,
right=1.75cm]{geometry}
\usepackage{titlesec}
\usepackage{fontspec}
% inline code (backticks in md)
% taken from https://jdhao.github.io/2019/05/30/markdown2pdf_pandoc/
\linespread{1.15}
\definecolor{bgcolor}{HTML}{e0e0e0}
\let\oldtexttt\texttt
\renewcommand{\texttt}[1]{
\colorbox{bgcolor}{\oldtexttt{#1}}
}
% change boldfont bold to extrabold
% \setmainfont[
% BoldFont={Inter-ExtraBold}
% ]{Inter}
% change regular font to light font
% \setmainfont{Inter light}
\newfontfamily\titlefont{Inter}[
UprightFont = *-Regular,
BoldFont = *-ExtraBold,
]
\newfontfamily\sectionsfont{Inter}[
UprightFont = *-Regular,
BoldFont = *-SemiBold,
]
\titleformat{\section}
{\titlefont\huge\bfseries}
{}
{0em}
{}
\titleformat{\subsection}
{\sectionsfont\LARGE\bfseries}
{}
{0em}
{}
\titleformat{\subsubsection}
{\sectionsfont\Large\bfseries}
{}
{0em}
{}
\titleformat{\paragraph}
{\sectionsfont\large\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\subsubsection}
{0pt}{2.5ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titleformat{\subparagraph}
{\normalfont\large\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\subparagraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
EDIT2: this is the .tex output part showed in the screenshot
taken from:
pandoc --pdf-engine=xelatex file.md -o file.tex
eléctrica que efectúa el campo sobre la partícula. se puede calcular entonces como:
\[\frac{w_{a \rightarrow b}}{q_{0}} = - \int_{a}^{b} \vec{e} \cdot d\vec{l} = v_{b} - v_{a} = v_{ab}\]
donde \({q_{0}}\) es una pequeña carga puntual, \(v_{a}\) y \(v_{b}\) el potencial por unidad de carga de los puntos \(a\) y \(b\) respectivamente, \(\vec{e}\) el valor del campo eléctrico

How to work around ImageJ run("HSB stack") error/ bug?

I am working on a macro for ImageJ. The goal is to take colour scans with several seeds on them and crop around the seeds to get several equally sized images with one seed on each.
This is the basic idea for the macro: prompt to select folder with scans (info about the seed is in the name of the image) > threshold to select seeds > crop around each seed on the original image > save all of the cropped images in a folder (name of the cropped images still containing the information of the name of the original image)
When I run the code below, I get an error for line 31: run("HSB stack");
The error informs me about supported conversions and shows that in order to run this command I need to start with an RGB image. However, according to Fiji > Image > Type, my images are RGBs. A coding error in that part also seems unlikely since it was written with the recording function in ImageJ.
Error message
According to what I found for the error, this seems to concern a recurring bug in the software, specific to the commands run("HSB stack") and run("RGB stack") in macros.
We have tried running this on ImageJ 2.3.0/1.53s as well as 1.53q on MacOS and Windows and always got the same problem.
If it is not a software problem, where is the error? Or if it is, do you have any suggestions for workarounds or a different program that could perform the same job?
The images I am working with are colour scans, 600dpi, white background with between 1 and 90 seeds on each scan. They are large tiff images (107.4 MB) but look like this:
Example scan image
I am not sure if it is helpful, but the code is below. There are probably still errors in the latter part that I could not yet get to because I can't get past the problem in line 31.
// Directory
dir=getDirectory("Choose a data folder");
list = getFileList(dir);
processed_dir_name = dir + "Cropped" + File.separator;
print(processed_dir_name);
File.makeDirectory(processed_dir_name);
// Batch
for (i=0; j<list.length; i++) {
print(i + ":" + dir+list[i]};
// Open images
run("Bio-Formats Importer", "open=" + dir+list[i] + "color_mode=Default view =Hyperstack");
// Crop edge, set general cropping parameters, scale
makeRectangle(108, 60, 4908, 6888);
run("Crop");
main = getTitle():
default_crop_width = 350;
default_crop_height = 350;
run("Set Scale...", "distance=600 known=25.4 unit=mm global");
//Thresholding
run("Color Threshold...");
//Color Thresholder 2.3.0/1.53q
// Autogenerated macro, single images only!
min=newArray(3);
max=newArray(3);
filter=newArray(3);
a=getTitle();
run("HSB stack");
run("Convert Stack to images");
selectWindow("Hue");
rename("0");
selectWindow("Saturation");
rename("1");
selectWindow("Brightness");
rename("2");
min[0]=0;
max[0]=255;
filter[0]="pass";
min[1]=0;
max[1]=255;
filter[1]="pass";
min[2]=0;
max[2]=193;
filter[2]="pass";
for (i=0;j<3;i++){
selectWindow(""+i);
The problem lies in the fact that your image is a hyperstack, and the color thresholding doesn't know how to work with that.
There are a few options you could try: Open the image as an 8-bit RGB, e.g. via open(dir+list[i]); or split the channels of the hyperstack and threshold each separately. Based on your sample image, I assume the first option makes more sense.
The following is an edited version of your code that works for the sample that you've provided:
// Directory
dir=getDirectory("Choose a data folder");
list = getFileList(dir);
processed_dir_name = dir + "Cropped" + File.separator;
print(processed_dir_name);
File.makeDirectory(processed_dir_name);
// Batch
for (i=0; i<list.length; i++)
{
if (!File.isDirectory(dir+list[i])) // Ignore directories such as processed_dir_name
{
print(i + ":" + dir+list[i]);
// Open images
open(dir+list[i]);
// Crop edge, set general cropping parameters, scale
makeRectangle(108, 60, 4908, 6888);
run("Crop");
main = getTitle();
default_crop_width = 350;
default_crop_height = 350;
run("Set Scale...", "distance=600 known=25.4 unit=mm global");
//Thresholding
//run("Color Threshold...");
//Color Thresholder 2.3.0/1.53q
// Autogenerated macro, single images only!
min=newArray(3);
max=newArray(3);
filter=newArray(3);
a=getTitle();
run("HSB Stack");
run("Convert Stack to Images");
selectWindow("Hue");
rename("0");
selectWindow("Saturation");
rename("1");
selectWindow("Brightness");
rename("2");
min[0]=0;
max[0]=255;
filter[0]="pass";
min[1]=0;
max[1]=255;
filter[1]="pass";
min[2]=0;
max[2]=193;
filter[2]="pass";
for (j=0;j<3;j++){
selectWindow(""+j);
}
}
}

Blank LatexPDF File issue with custom Latex Style with SPHINX

Recently I've created my PDF file correctly as in style formatting.
But now I've got the issue that my RST files from Sphinx are not included.
Maybe that someone knows how I include the RST content into the custom PREAMBLE - sty file content
main.sty
\PassOptionsToPackage{english}{babel}
\usepackage{amsmath}
\usepackage{color,pxfonts,fix-cm}
\usepackage{latexsym}
\usepackage[mathletters]{ucs}
\DeclareUnicodeCharacter{32}{$\ $}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pict2e}
\usepackage{wasysym}
\usepackage{tikz}
\pagestyle{empty}
\geometry{left=0.2in, top=0.5in, paperwidth=595pt, paperheight=878pt}
\begin{document}
\definecolor{color_93343}{rgb}{0.25098,0.25098,0.25098}
\definecolor{color_217206}{rgb}{0.737255,0.839216,0.443137}
\begin{tikzpicture}[overlay]\path(0pt,0pt);\end{tikzpicture}
\begin{picture}(-5,0)(2.5,0)
\put(-15,-837.4999){\includegraphics[width=596.25pt,height=887.25pt]{latexImage_ab7aceb12f4add82da5ce423202fd278.png}}
\put(55.775,-99.78003){\fontsize{11}{1}\usefont{T1}{cmr}{m}{n}\selectfont\color{color_93343} }
\put(55.525,-810){\fontsize{11}{1}\usefont{T1}{cmr}{m}{n}\selectfont\color{color_93343} }
\put(282.38,-810){\fontsize{11}{1}\usefont{T1}{cmr}{m}{n}\selectfont\color{color_93343} }
\put(509.48,-810){\fontsize{11}{1}\usefont{T1}{cmr}{m}{n}\selectfont\color{color_93343} }
\put(55.775,-823.5){\fontsize{11}{1}\usefont{T1}{cmr}{m}{n}\selectfont\color{color_93343} }
\put(55.775,-118.05){\fontsize{16}{1}\usefont{T1}{cmr}{b}{n}\selectfont\color{color_217206} }
\put(55.775,-150.3){\fontsize{16}{1}\usefont{T1}{cmr}{b}{n}\selectfont\color{color_217206} }
\end{picture}
\end{document}
[SPHINX] Conf.py:
latex_engine = 'pdflatex'
latex_additional_files = [
'latexImage_ab7aceb12f4add82da5ce423202fd278.png',
'main.sty'
]
latex_elements = {
# Additional stuff for the LaTeX preamble.
'extraclassoptions': 'openany',
'preamble' : r"""
\usepackage{main}
\renewcommand{\subtitle}{%s}
""" % (project)
}
It creates the latex PDF with the correct custom styling.. But all the RST content is not included.
I also tried it with 'latex_documents' Creation method within the conf.py but resulted also with a blanko PDF file.

How to add latexbangla in book document class?

When I am using the latexbangla package
\usepackage[banglamainfont=Kalpurush, banglattfont=Siyam Rupali,
feature=0, changecounternumbering=0]{latexbangla}.
\newfontfamily{\bengalifontsf}[Script=Bengali]{Noto Sans Bengali}
in the following book documentation class, the header footer is not working.
MWE:
\documentclass[twoside,12pt,english]{book}
%\usepackage[banglamainfont=Kalpurush, banglattfont=Siyam Rupali, feature=0, changecounternumbering=0]{latexbangla} % to write bengali in latex
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage{color}
\definecolor{marron}{RGB}{60,30,10}
\definecolor{darkgray}{RGB}{0,80,0}
\usepackage[demo]{graphicx}
\usepackage{wallpaper}
\usepackage{fancyhdr}
\usepackage{geometry}
\geometry{
tmargin=5cm,
bmargin=5cm,
lmargin=5cm,
rmargin=3cm,
headheight=1.5cm,
headsep=0.8cm,
footskip=0.5cm}
\usepackage{fourier-orns}
\newcommand{\ornpar}{\noindent \textcolor{darkgray}{ \raisebox{-1.9pt}[10pt][10pt]{\leafright} \hrulefill \raisebox{-1.9pt}[10pt][10pt]{\leafright \decofourleft \decothreeleft \aldineright \decotwo \floweroneleft \decoone}}}
\makeatletter
\def\headrule{{\color{darkgray}\raisebox{-2.1pt}[10pt][10pt]{\leafright} \hrulefill \raisebox{-2.1pt}[10pt][10pt]{~~~\decofourleft \decotwo\decofourright~~~} \hrulefill \raisebox{-2.1pt}[10pt][10pt]{ \leafleft}}}
\makeatother
\fancyhf{}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\newcommand{\estcab}[1]{\itshape\textcolor{marron}{\nouppercase #1}}
\fancyhead[LO]{\estcab{\rightmark}} % malo cuando no hay section ~~~ \thesection
\fancyfoot[RE]{\ornpar \\ \large \sffamily\bf \textcolor{darkgray}{\thepage ~~~ \reflectbox{\leafNE}} \hfill}
\pagestyle{fancy}
\renewcommand{\footnoterule}{\vspace{-0.5em}\noindent\textcolor{marron}{\decosix \raisebox{2.9pt}{\line(1,0){100}} \lefthand} \vspace{.5em} }
\usepackage[hang,splitrule]{footmisc}
\addtolength{\footskip}{0.5cm}
\setlength{\footnotemargin}{0.3cm}
\setlength{\footnotesep}{0.4cm}
%\newfontfamily{\bengalifontsf}[Script=Bengali]{Noto Sans Bengali}
\begin{document}
\tableofcontents
\chapter{First Chapter}
\newpage
\section{New Section}
\end{document}
Without using latexbangla package, everything is working fine. But I want to use latexbangla and the header footer should be the same as below.
How do I do it?

CMS and store hi-resolution images in generated pdf

I'm looking for good CMS for publishing software manuals.
Requirements:
publish manual pages as web pages with thumbnails and shows full resolution after click on image,
exporting manual pages to a pdf file with full resolution images instead to thumbnails.
I found IMHO best wiki system named Tiki Wiki (https://info.tiki.org/) but when I export to pdf then I gets low resolution thumbnail.
I solve this problem by very simple Tiki Wiki code modification:
Modify lib/wiki-plugins/wikiplugin_img.php to force using full image resolution instead to thumbnail in print page mode (inserted code 1) and rescale images in generated HTML by 0.5 factor (inserted code 2):
[...]
function wikiplugin_img( $data, $params )
{
[...]
$imgdata = array_merge($imgdata, $params);
// inserted code 1 (~410 line)
if ($GLOBALS['section_class']=="tiki_wiki_page print"){
$imgdata['thumb'] = '';
}
// end of inserted code 1
//function calls
if ( !empty($imgdata['default']) || !empty($imgdata['mandatory'])) {
[...]
$fwidth = '';
$fheight = '';
if (isset(TikiLib::lib('parser')->option['indexing']) && TikiLib::lib('parser')->option['indexing']) {
$fwidth = 1;
$fheight = 1;
} else {
// inserted code 2 (~410 line)
if ($GLOBALS['section_class']=="tiki_wiki_page print"){
$fwidth = $imageObj->get_width() / 2;
$fheight = $imageObj->get_height() / 2;
} else {
$fwidth = $imageObj->get_width();
$fheight = $imageObj->get_height();
}
// end of inserted code 2 (~638 line)
}
[...]
Now, after printing to pdf by wkhtmltopdf we gets pdf with small but full resolution images.
Additional modifies:
Adds following lines to cms/cssmenus.css (or other css included in print mode) for increase bottom margin of image caption:
div.thumbcaption {
margin-bottom: 5mm;
}
Removes lines from 171 to ~175 in templates/tiki-show_content.tpl for remove the "The original document is available at" foot.