RMarkdown pdf - Font color - pdf

How can I change the font color in RMarkdown pdf output.
I did try doing, Roses are \textcolor{red}{red}, violets are \textcolor{blue}{blue}.
But this only worked for the very first line in the pdf document. Upon using the same subsequently, it outputs this error,
! File ended while scanning use of \#xdblarg.
<inserted text>
\par
<*> /tmp/tex2pdf.18828/input.tex
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on /tmp/tex2pdf.18828/input.log.
pandoc: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43
Execution halted
Help appreciated!
Thank you

Related

Pandoc convert md with image to pdf

My md file contains a list of images like:
"! [image-9H7092HQ.jpg] (Beginners_Russian_with_Interactive_Online_Workbook/image-9H7092HQ.jpg)"
"! [image-EVZX3ID8.jpg] (Beginners_Russian_with_Interactive_Online_Workbook/image-EVZX3ID8.jpg)"
(There is no space between "!" and "[", and "]" and "(")
The images are in the another file that is in the same file as md file.
I ran
pandoc -f markdown -t pdf Beginners_Russian_with_Interactive_Online_Workbook.md
on terminal, but it gives me error:
Error producing PDF.
! LaTeX Error: Too many unprocessed floats.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.378 \centering
Then I ran
H <return>
it returns
zsh: parse error near `\n'
I am not sure what went wrong. And how I can turn this md file with images to pdf. I will be very appreciated if anyone can help me. Thanks.
The main problem is fixed, but there is a dimension problem with the output file(see below)
The likely issue is that pandoc converts images without surrounding text into figures. Try
pandoc -f markdown-implicit_figures -t latex -o OUTFILE.pdf YOUR-FILE.md
That should disable this feature and solve the issue.

Why text is missing after convert this PDF to image using ImageMagick/Ghostscript?

Text is missing after convert this pdf to image(png or jpg), but there no any error log.
Use ImageMagick:
convert -density 150 -quality 100 "d:/t/pdf/fp.pdf" -alpha Remove "d:/t/pdf/5/fp.png"
Use Ghostscript (testing with version 9.23 and 9.25):
gswin64 -dSAFER -dBATCH -dNOPAUSE -r300 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=jpeg -sOutputFile=D:\t\pdf\123.jpg D:\t\pdf\fp.pdf
Anyone know what the reason and how to solve it? Thx.
PDF File for testing
image 1 image 2
There are two CIDFonts (STSong-Light and AdobeKaitiStd-Regular) used but not embedded. This means that a substitute font must be used. When run through Ghostscript this produces the following transcript:
GPL Ghostscript GIT PRERELEASE 9.26 (2018-09-13)
Copyright (C) 2018 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
Can't find CID font "AdobeKaitiStd-Regular".
Attempting to substitute CID font /Adobe-GB1 for /AdobeKaitiStd-Regular, see doc
/Use.htm#CIDFontSubstitution.
The substitute CID font "Adobe-GB1" is not provided either. attempting to use fa
llback CIDFont.See doc/Use.htm#CIDFontSubstitution.
Loading a TT font from %rom%Resource/CIDFSubst/DroidSansFallback.ttf to emulate
a CID font Adobe-GB1 ... Done.
Can't find CID font "AdobeKaitiStd-Regular".
Attempting to substitute CID font /Adobe-GB1 for /AdobeKaitiStd-Regular, see doc
/Use.htm#CIDFontSubstitution.
Can't find CID font "AdobeKaitiStd-Regular".
Attempting to substitute CID font /Adobe-GB1 for /AdobeKaitiStd-Regular, see doc
/Use.htm#CIDFontSubstitution.
Loading NimbusSans-Regular font from %rom%Resource/Font/NimbusSans-Regular... 71
35536 5791889 4867288 3488798 3 done.
Can't find CID font "STSong-Light".
Attempting to substitute CID font /Adobe-GB1 for /STSong-Light, see doc/Use.htm#
CIDFontSubstitution.
Loading NimbusMonoPS-Regular font from %rom%Resource/Font/NimbusMonoPS-Regular..
. 10713600 9353422 4987912 3610458 3 done.
**** Error: Executing Do inside a text block, attempting to recover
Output may be incorrect.
>>showpage, press <return> to continue<<
So you can see two fonts being substituted, and then a more concrete problem. Your PDF file executes an image operator inside a text block, which is illegal. However for me the output is apparently correct.
[EDIT]
There is some odd behaviour here. I downloaded the 64-bit release code last night and tried that, and I do see the error. The back channel transcript contains this :
Can't find CID font "AdobeKaitiStd-Regular".
Attempting to substitute CID font /Adobe-GB1 for /AdobeKaitiStd-Regular, see doc
/Use.htm#CIDFontSubstitution.
Loading NimbusSans-Regular font from %rom%Resource/Font/NimbusSans-Regular... 77
20460 6369217 2670672 1276767 3 done.
**** Error: can't process embedded font stream,
attempting to load the font using its name.
Output may be incorrect.
**** Error reading a content stream. The page may be incomplete.
Output may be incorrect.
Loading NimbusMonoPS-Regular font from %rom%Resource/Font/NimbusMonoPS-Regular..
. 11808228 10439970 2690872 1310356 3 done.
**** Error: Executing Do inside a text block, attempting to recover
Output may be incorrect.
**** Error: File did not complete the page properly and may be damaged.
Output may be incorrect.
Page 2
The key part is "Can't process embedded font stream....' That's why your text is going missing.
When I run the same command line using the current HEAD of our Git repository I don't see this error, and the file runs to completion. So it looks like this was a bug which has been fixed.
You have two options;
1) If you don't mind building the code, clone our Git repository, open the Visual Studio solution file, allow VS to update it to your version, then build Ghostscript. Use that binary.
2) As you've already discovered, don't use SAFER. I should caution you that this is a potentially dangerous setup. As long as you are processing files which you created yourself you should be fine, but please don't use this setup to process random files from untrusted sources, you could be laying yourself open to attack.
[edit 2]
And here's a third option. With 9.25 we started shipping the Resource files with Windows, just as we do with Linux. I suspect that if you add -I"c:/program files/gs/gs9.25/Resource/Init" to the beginning of your command line, it will work even when -dSAFER is true.
BTW its useful to quote the messages from the back channel when you have a problem, it may not tell you much, but it has useful information for PostScript developers.
The missing text came back when I removed the parameter -dSAFER. I don't understand why; I can't find the reason in the Ghostscript documentation.
This is my final command line:
gswin64 -dBATCH -dNOPAUSE -r150 -sDEVICE=jpeg -sOutputFile=D:\t\pdf\6\fp%03d.jpg D:\t\pdf\fp.pdf

Emoji don't knit to PDF

If I run cat("\U001F615") on the command line in RStudio on my Mac, it shows the emoji. But if I knit it (Rmd) into a pdf, I get this error message:
! Package inputenc Error: Unicode char \u8:😕 not set up for use with
LaTeX.
See the inputenc package documentation for explanation. Type H
for immediate help. ...
l.144 \end{verbatim}
Try running pandoc with --latex-engine=xelatex.
pandoc:
Error producing PDF Error: pandoc document conversion failed with
error 43 Execution halted
But if I do latex_engine: xelatex, I don't get an error message, but the knitted pdf still doesn't show the emoji. Can someone help me in how I can knit to PDF with Emoji displaying?
There is a LaTeX package that adds support for emoji here: https://github.com/alecjacobson/coloremoji.sty
I haven't had any luck installing it though, because it's not on CTAN yet and I'm a LaTeX noob!
Once it's installed, you can add something like this to your YAML header:
---
title: "Title"
author: "Me"
header-includes:
- \usepackage{coloremoji}
output:
pdf_document
---

Importing *.pdf_tex file error

I have made a graphic with inkscape. Now I'm trying to build it in Latex. I' m working with TEXMaker. Therefore I have exported my graphic as *.pdf_tex and *.pdf.
In macros i have added the following
\usepackage{color}
\usepackage{transparent}
\graphicspath{{fileWithPictures/}}
my picture is build in like this:
\begin{figure}
\centering
\def\svgwidth{175pt}
\input{fileWithPictures/pic.pdf_tex}
%\includegraphics[width=2in]{fileWithPictures/pic.pdf_tex}
\end{figure}
Here I'm getting the following error. "!Package pdftex.def Error: File'pic.pdf" not found. See the pdftex.def package.."
I have tryed also to work with includegraphics which not succed. Because there he it doesn't recognize pdf_tex format.
Interesting is that the compiler says that there is not a file called "pic.pdf" and not "pic.pdf_tex". Althought both files are clearly in the file. To be sure i put the pic.svg file in the file. Now i have no more ideas and would be happy to get some help
Thanks
Use resizebox to set the width of your file instead of \def\svgwidth{175pt} it will solve your problem
\resizebox{\textwidth}{!}{
\input{fileWithPictures/pic.pdf_tex}
}

Conversion of Japanese fonts returns an error in pdf2swf

When i am issuing the command
pdf2swf japanese.pdf -o japanese.swf -f -T 9 -t -s storeallcharacters
conversion returns an error:
Error: Unknown font tag 'HGTT_0'
Error: Unknown font tag 'HGTT_1'
Error (27721): No font in show
Error: Unknown font tag 'HGTT_1'
Error (33717): No font in show
Error: Unknown font tag 'F0'
Error (38443): No font in show
Error: Unknown character collection 'Adobe-Japan1'
Error: Couldn't find '90msp-RKSJ-H' CMap file for 'Adobe-Japan1' collection
Error: Unknown CMap '90msp-RKSJ-H' for character collection 'Adobe-Japan1'
Error: Unknown font tag 'F0'
Error (244537): No font in show
I have checked the path file for CMAP in adobe and it shows that I have Adobe-Japan1 CMAP under C:\Program Files\Adobe\Reader 10.0\Resource\CMAP.
Then what I tried so far is to download CMaps for PDF CJK Fonts in here
Download CMAP for Japan
and replaced what is under the path. I am looking everywhere for fonts 'HGTT_0, HGTT_1, F0' in the web but still no luck. I research more of the problem and found out this Japanese Font conversion problem, might have some information I missed? Please help me to understand, why is pdf2swf still report for a notice that It cannot find 'Adobe-Japan1' collection wherein I actually have it?