Rendering this pandoc table - pandoc

+---------------+---------------+--------------------+
| Right | Left | Centered |
+==============:+:==============+:==================:+
| Bananas | $1.34 | built-in wrapper |
+---------------+---------------+--------------------+
I used the standard command
pandoc test.txt -o test.pdf
But I get the above unrendered text. Am I doing something wrong here?
I am new to pandoc tables. Are grid tables fundamentally different than other tables supported by pandoc markdown?

I managed to render this adapted version in stackedit.io
| Right | Left | Centered |
|-:|:-|:-:|
| Bananas | $1.34 | built-in wrapper |
And your version in pandoc/try, which did work as expected. Try specifying the input and output format, and also try a different output format to see if that works.

Related

Sphinx RST ERROR: Undefined substitution referenced: "$". in table

I am writing a sphinx rst table and one of the cells contains a certain symbol that errors.
Here is an example:
+--------+---------+
| Test | Field |
+--------+---------+
| |$| | Errors |
+--------+---------+
This results in ERROR: Undefined substitution referenced: "$"., even though this is the symbol I want in my table. It still shows up in the resulting documentation though.
|x| is recognized as a substitution reference, using \ to escape it should work for you.
+--------+---------+
| Test | Field |
+--------+---------+
| \|$| | Errors |
+--------+---------+
The solution I found was to simply surround |&| with two backticks:
``|$|``
It does make the text monospace, but it doesn't bother me. I no longer have the error in my console.

Taking notes: print two pages per sheet, one blank

I need an automation for PDFs that is a variant of multiple pages per sheet. In this case, I don't need a simple two-pages-per-sheet solution, that's easy. I need to take hand-written notes side by side to the pages. So, here it goes:
Given a PDF, I'd like to print it with two pages per sheet, however, one page must be blank, like this:
+-------+-------+
| P.1 | white |
| | |
| | |
+-------+-------+
+-------+-------+
| P.2 | white |
| | |
| | |
+-------+-------+
etc.
Has anyone an idea to write a script that can automate this?
PS. I know how to do this in LaTeX, but I'd like to avoid the big gun...
If avoiding LaTeX does not mean avoiding usage of any tools that depend on it, then PDFJam (Debian package is texlive-extra-utils) could be of help, see q/a: Gluing (Imposition) PDF documents.
Otherwise you are probably better off with a little script that converts .pdf file pages to images and then merges them with a blank image, ImageMagick is able to do those things.
With Ubuntu:
# install packages
sudo apt-get install enscript ghostscript pdfjam pdftk
source="source.pdf"
output="output.pdf"
# create ps with one blank page
echo -n | enscript -p blank.ps
# convert p2 to pdf
ps2pdf blank.ps blank.pdf
# get number of pages of $source
num=$(pdftk "$source" dump_data | grep -Po 'NumberOfPages: \K.*')
# create string with new page numbers
for ((i=1;i<=$num;i++)); do pages="$pages A$i-$i B1-1"; done
# create pdf with white pages
pdftk A="$source" B=blank.pdf cat $pages output tmp.pdf
# create pdf with two pages on one side
pdfjam tmp.pdf --nup 2x1 --landscape --outfile "$output"
# clean up
rm blank.ps blank.pdf tmp.pdf
I have a solution which does not print exactly the layout which you want, but prints the page centered in the landscape sheet, like so:
+---+-------+----+
| | P.1 | |
| | | |
| | | |
+---+-------+----+
+---+-------+----+
| | P.2 | |
| | | |
| | | |
+---+-------+----+
If you're goal is to create free space for hand annotations, this layout might be better since it lets you write the annotation closer to the printed text.
The following script relies on pdfjam which uses LaTeX under the hood. Probably adding a few more command line arguments for pdfjam would get exactly what you are looking for.
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "usage: $0 PDF_filename..."
echo
echo "This script takes a PDF file as command line arguments,"
echo "and generates a new, landscape-formatted PDF file, where every "
echo "page has very large margins which may be useful for editorial notes"
echo
echo "Requires: pdfjam, which is installed by the apt-get package texlive-extra-utils"
exit 1
fi
command -v pdfjam >/dev/null 2>&1 || { echo >&2 "I require pdfjam but it's not installed. Do an apt install of texlive-extra-utils to get it on Ubuntu. Aborting."; exit 1; }
pdfjam --batch --nup 1x1 --suffix widemargin --landscape "$#"

Ditaa not aligning

It should be clear to know (for a human) what I want this ditaa-input file to look like
/---------------------------\
| TEST |
+--------------+------------+
| foo() | "yuck < 3" |
+--------------+------------+
| bar() | NEVEREVER! |
+--------------+------------+
| antlioneater | (x>5) || d |
\--------------+------------/
But it doesn't. Look at the less/greater signs. Plus, that is one out-of-shape antlioneater!
What am I doing wrong? I invoked ditaa v0.9 as ditaa -E -e utf8 test.txt.
I suggest using another character that looks like it, for example ‹ and ›.
It's a bit of a trick, but since the output of ditaa is an image anyway, having a visually similar character is usually good enough.
I personally use this to embed HTML markup in my ditaa charts.
Ditaa parses > and < as arrow heads even if they are not attached to a line ( --> ), hence the weird rendering. It's unfortunate, but that's how it is!

solution for combining two text files missing different headers

I am running in a windows environment and have not used grep/awk/sed/shell; however, I would like to know what would be the simplest solution for the following issue:
I have two files (they both have headers):
Genetics File. The columns are Animal, Car, Color
Specimen File. The columns are Animal, Color
I would like to combine the two file into one file with all headers present; however, for the specimen file portion to have blank values for Car. The end product would be:
+----------+------+-------+---------------------------------------------------------------------+
| Animal | Car | Color | |
+----------+------+-------+---------------------------------------------------------------------+
| Elephant | Jeep | Grey | (from genetics file [don’t include this text in the resulting file) |
| Dog | Ford | Red | (from genetics file) |
| Cat | | Blue | (from specimen file) |
| Donkey | | Green | (from specimen file) |
+----------+------+-------+---------------------------------------------------------------------+
What would be the simplest solution in a windows environment?
edit: to clarify the reason for those tags is because i believe that those tools are the best suited for this job! I do not want to create a whole c# application just to do this.
The tools referred to in the question, sed, awk, grep, etc., are not native to Windows.
In order to use those them, you will have to make a choice:
Install a unix or linux on your computer, either native, or through virtualisation.
or:
Install a toolkit like Cygwin or UWIN
There's a lot of documentation out there for these projects, but there's a lot to learn, if you're new.
An easy way to get started with virtualisation is to get Oracle's Virtualbox, and a copy of ubuntu linux.
Is this what you want ?
$cat input.ani
|Elephant|Jeep|Grey|
$ cat input.Specimen
| Cat | Blue |
| Dog | White |
| Elephant | Red |
$ cat input.Specimen | awk '{print $1 $2 $3 " " $3 $4 $5 $6 }' >> input.ani
$ cat input.ani
|Elephant|Jeep|Grey|
|Cat| |Blue|
|Dog| |White|
|Elephant| |Red|
On second thought, for a simple solution, I would not recommend against the unix toolset, unless you really want to get learn the environment.
For a Windows system, you could just as well install a good scripting language like python, perl, or ruby.
None of those is trivial, but they have good support, and they have decent installers for windows.
Yet another alternative would be PowerShell, which again, is based on the .Net runtime.

Problem with including an "image" in shell program

I'm writing a program where at some point in my loop I want to print to output whatever is stored in a separate file (an image). But if I code it like this:
for c in $LIST
do
clear
./image.0
done
And the "image.0" file contains only an image like this:
+----+
| |
|
|
|
|
|
========
Then when I run my program I get this message:
./image.0: 1: +----+: not found
./image.0: 2: Syntax error: "|" unexpected
Why?
================================
So "cat" works, the image appears in the output but it's shifted in a strange way.
Do you know why this would happen?
+----+
| |
|
|
|
|
|
========
Answer: I put printf "\n" that fixed the shifting image
With ./image.0, you tell the shell to execute the image. You want to output it, so use cat image.0
Try to use the command cat to output the content of the image.0 file
cat ./image.0
./something will take something as a program and execute it. That's not what you want : to display the contents of a file, you can use the cat command, like this :
for c in $LIST
do
clear
cat image.0
done

Resources