Archive | LaTeX

# Some random BibTeX bibliography style examples

Here we have some basic BibTeX bibliography styles, with a few of the key distinguishing features pointed out.

Well howdy

# gsftopk and 8.3 filenames

Note to self — nothing to see here.

I sometimes play with emTeX inside DOSBox. The DVI viewer is very nice.

Sometimes, I have a font that the DVI viewer will not render, even though I can LaTeX and (often) dvips the file no worries. The viewer, dviscr, needs packed bitmap pixel files (xxxx.pk) of each size, and in the right place in the emTeX directory tree, usually in C:\TEXFONTS.

Say I want to generate the pncr8r pk file at 180 size, using the old DOS file name convention, then put it where dviscr will find it.

I sometimes use the the Linux machine that hosts the DOSBox session:

$gsftopk --dosnames pncr8r 180 gsftopk(k) version 1.19.2/927 [1] [2] [3] [4] [5] [6] [7] [8] [9] [11] [12] [14] [15] [16] [17] [30] [31] [32] [33] [34] [35] [36] [37] [38] [39] [40] [41] [42] [43] [44] [45] [46] [47] [48] [49] [50] [51] [52] [53] [54] [55] [56] [57] [58] [59] [60] [61] [62] [63] [64] [65] [66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76] [77] [78] [79] [80] [81] [82] [83] [84] [85] [86] [87] [88] [89] [90] [91] [92] [93] [94] [95] [96] [97] [98] [99] [100] [101] [102] [103] [104] [105] [106] [107] [108] [109] [110] [111] [112] [113] [114] [115] [116] [117] [118] [119] [120] [121] [122] [123] [124] [125] [126] [130] [131] [132] [133] [134] [135] [136] [137] [138] [139] [140] [147] [148] [149] [150] [151] [152] [153] [154] [155] [156] [159] [161] [162] [163] [164] [165] [166] [167] [168] [169] [170] [171] [172] [173] [174] [175] [176] [177] [178] [179] [180] [181] [182] [183] [184] [185] [186] [187] [188] [189] [190] [191] [192] [193] [194] [195] [196] [197] [198] [199] [200] [201] [202] [203] [204] [205] [206] [207] [208] [209] [210] [211] [212] [213] [214] [215] [216] [217] [218] [219] [220] [221] [222] [223] [224] [225] [226] [227] [228] [229] [230] [231] [232] [233] [234] [235] [236] [237] [238] [239] [240] [241] [242] [243] [244] [245] [246] [247] [248] [249] [250] [251] [252] [253] [254] [255]$ cp pncr8r.pk /path/to/TEXFONTS/PIXEL.LJ/180DPI/

Then, back in DOSBox, refresh the file tree

Ctrl+F4

Then it works.

Note that the main difference between pk files on Linux and DOS is that DOS can only use 8.3 file names, so it omits the scale number (180 in this case), which means that copying into the correct directory, with name of the form XXXDPI where XXX is the number, is vital because that is how dviscr selects the correct pk file.

Note also that dvips will resort to using the .pk files to generate the PostScript if there is no PostScript font available, so doing this will sometimes fix missing glyphs in dvips output.

emTeX

# LaTeX — box several paragraphs of text tightly

I found that for some reason an fbox around a minipage did not work for me — it did away with the paragraphing and turned it into one giant line. So instead I did this:

\documentclass{article}

\usepackage{bera}

\begin{document}

% Set width of minipage (minpagw) to length of longest line by using
% the line as as argument to \settowidth

\newlength{\minpagw}
\settowidth{\minpagw}{This is definitely the longest line, for sure.}

\begin{minipage}{\minpagw}
\fbox{%
\parbox{\linewidth}{%
Not the longest.

New paragraph, but not longest line.

This is definitely the longest line, for sure.

This isn't

Nor is this.
}%
}%
\end{minipage}

\end{document}

Which gives this:

Boxed text, multiple paragraphs, tight box.

As requested.

# PDF to emf or svg for putting vector graphics in Word

Started with multipage PDF document.

Cropped out the bit I wanted.

First, I extracted the page I wanted. I have all the Poppler stuff installed in Cygwin, so:

$pdfseparate -f 4 -l 4 whatiscc1.pdf page4.pdf (-f means first page to extract, -l means last) Then I cropped out the bit I wanted of that page 4. I did that by opening it in gv and noting the pixel coordinates. I used pdfcrop from TeXLive, and I’ll confess I iterated a few time to get the coordinates I wanted. Remember that it trims off white space then adds margins, so the margin option works relative to the crop box, not the original page! $ pdfcrop --margins "-52 -250 -20 -25" page4.pdf page4-crop.pdf

So now I had my PDF image.

GUI

Fired up Inkscape and use the internal import, but that looked a mess.

Tried ‘Poppler/Cairo’ import — looked good.

Saved as an Inkscape svg, wmf and emf, using default settings.

Back in Word — Insert → PIcture Chose the emf; looked good. So did the wmf and the svg.

Now, it is not a complex image with many paths, gradients, fills etc, so YMMV.

Command line

Inkscape can also be used thus:

$inkscape.exe page4-crop.pdf -l page4_test.svg And this svg file was fine too. Note that the command line use seems to use the native PDF import, which is not as good as the Poppler/Cairo-based one. I have had a couple of occasions when the command line run did not work and I used Poppler/Cairo import via the GUI. Inkscape. # Installing pdfjam on Cygwin: I’m stupid (plus: manual install of man pages) ### Context Cygwin installed on Win 10, MikTeX installed natively on Win 10; no LaTeX installed within Cygwin. ### What I should not have done Inside a Cygwin terminal: $ cd installs/
$mkdir pdfjam$ cd pdfjam
$wget http://www2.warwick.ac.uk/fac/sci/statistics/staff/academic/firth/software/pdfjam/pdfjam_latest.tgz$ tar x -vzf pdfjam_latest.tgz


Copied the contents of pdfjam/bin to my userspace local Cygwin bin directory.

$cp bin/* ~/bin  Manuals — opened the file that sets them up on Cygwin: $ vim /etc/man_db.conf


Added this to the file at end of MANPATH_MAP section:

MANPATH_MAP     /home/darren/bin        /home/darren/manpages


Add this to end of MANDB_MAP section

MANDB_MAP       /home/darren/manpages   /home/darren/manpages


Then created my local manpages directory and copy the man1 folder in there.

$cp -r man1 ~/manpages/  Restarted Cygwin OK, man pages worked. pdfjam --help  worked. OK, tested it… $ pdfnup filename.pdf


Nothing happened…

### What worked was simpler and I should have done it first

Maybe it’s the LaTeX environment…?

Which Cygwin package has pdflatex in it?

In fact, texlive-collection-binextra has pdfjam in it… can probably install that and uninstall local install of pdfjam. OK, I guess I’ll have to install LaTeX in Cygwin…

$apt-cyg install texlive-collection-binextra  Might well install pdflatex as a dependency anyway. OK, ran that; at least it threw an error — it wanted pdfpages… texlive-collection-latexrecommended Installed some stuff via Cygwin setup-XXX.exe; main LaTeX packages like texlive-collection-latexrecommended and so on. Still it did not find pdfpages… Was LaTeX initialised correctly? $ texconfig-sys init


And yes, now pdfnup worked.

pdfnup --batch --suffix 'twoup' 2-13_cutepdf-crop.pdf  So for whatever reason (and it is not unreasonable) the pdfjam that was running in Cygwin did not like the pdflatex stuff installed native to Windows by MikTeX. Since the computer in question has a wired connection to an office network, the big downloads associated with this ‘blunt instrument’ solution of basically installing LaTeX on Cygwin did not matter, but they might on a more constrained network. Doofus. On the other hand, I now know how to manually install man pages. # $$math$$ versus $math$ in LaTeX Let’s say you want to display some maths in LaTeX. You don’t want to use equation and related environments. Inline maths is enclosed between dollar signs, and is formatted as part of the sentence. A displayed equation is enclosed between pairs of dollars or between $and$. But $$…$$ and $…$ are not the same. For one thing, $…$ responds to the documentclass option fleqn to align the equations to the left rather than center them. Thus, we get this: Where ‘Inline’ is indented because it starts a paragraph. First two displayed equations use $$…$$ and are centred, the last uses $…$ and is indented by a length called mathindent. Here is the LaTeX code \documentclass[fleqn]{article} \begin{document} Inline maths: a simple equation might bex+y=1. The solutions to the quadratic equation $$ax^2 + bx + c = 0$$ are given by $$x=\frac{-b \pm \sqrt{b^2-4ac}}{2a},$$ which is to say $x=\frac{-b \pm \sqrt{b^2-4ac}}{2a}.$ \end{document}  Notice the argument ‘fleqn’ has been given to the article class, but $$…$$ did not obey it. $…$ did, but not all the way to the left. If you want the left aligned maths to be hard left, you need to redefine mathindent to be zero length: \setlength{\mathindent}{0pt}  and this gives Anyway. # Non-breaking en rule (en dash) in Microsoft Word… not really (or so I thought). Say you’ve got a number range. The proper way to format that is with an en rule (en dash), so it looks something like ‘4­–5’ whereas a hyphen would look like ‘4-5’. Now, you probably don’t want the number range to break across lines. That’s fine with a hyphen, since Ctrl-Shift-Hyphen gives a non-breaking hyphen (in Word). But you don’t want a hyphen you want an en rule. One option is to put in a non-breaking hyphen then make it twice as wide. • Highlight the non-breaking hyphen (and the hyphen alone, not any trailing/leading characters or spaces). • Right click on the hyphen and select the ‘Font…’ menu, then ‘Advanced’ (rule #1 in Microsoft products: Just about anything worth doing is considered ‘Advanced’). • Change the number in the ‘Scale’ box to be about 200%. • Exit from the menus. • Type an en rule in your document, alongside the stretched hyphen. (Ctrl-Keypad Minus.) • Compare. • Swear. • Use it anyway since it’s the most reasonable alternative. You may want to adjust the height; but will this highly manual fix work if font is then changed? No. • Watch while Word mysteriously moves the instruction to widen the characters to random places in the document so you end up with double width text in unexpected places. • Swear. • Learn LaTeX where all you need to type is \mbox{4–5}. Stretch out the hyphen (or anything else) using the ‘Scale’ box. Gives fixed selections but can type in other values. Something between 175% and 225% usually works. Note: Can also be used to adjust the position if need be. I have tried putting text in boxes, but the baseline is not maintained – it sits high. Character positions can be adjusted down, but then Word boxes clip the contents. Perhaps there is a better solution? I tried making it an equation, or using a minus character, but neither was really satisfactory. The minus does not sit at quite the right height, though it may well be the best solution, in truth. I’d like to hear about a better answer because, sadly, using LaTeX is not always viable. Non-breaking en rule in Word; results of stretching a hyphen. My Word. # My new work profile. I am now officially an editor… http://www.biotext.com.au/staff/darren-goossens/. From the company website: A grab from the Biotext website, as it was in May 2017. Further updates as they come to hand… # The Sharp MZ-721 font in a terminal emulator Long ago I made a LaTeX font out of the character glyphs from the Sharp MZ-721 8-bit microcomputer. Then I made a font for use in a terminal emulator. How did I do it? From the below, I seem to have used the pk file generated when the font was used in LaTeX, then realised I could go direct from the original Sharp character ROM. I made a bdf file, which is an old but usable format. You can download it from here, and the crap below will help you install it if you need help. But you can google ‘installing bdf fonts’ and get something more useful. And edit the fonts to make them better. Or not,. whatever. I don’t remember any details. Here is the contents of a ‘note to self’ file I wrote at the time… _________________________________________________________________ Installed gbdfed for AMD64 by downloading the following package: Package: gbdfed (1.5-1.1) https://packages.debian.org/squeeze/gbdfed squeeze (oldoldstable) (x11): X11 font editor 1.5-1.1: amd64 armel i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc s390 sparc then  sudo dpkg -i gbdfed_1.5-1.1_amd64.deb

and it seems to work. Opened the pk file for the first MZ font and then saved as bdf. That is all so far.

How to use a BDF font file…

move it to

~/.fonts/mz/MZ7CGint.bdf
$cd .fonts$ mkfontdir
$cd mz$ mkfontdir
$chmod 644 *$ xset fp+ $HOME/.fonts/mz$ xset fp rehash


If I go to the.fonts/mz and type

xterm -fn -unknown-mz7cgint-medium-r-normal–83-100-600-600-p-530-fontspecific-0

it works but the font is enormous, since it is just mapped directly as
a 600x600 bitmap.  Needs to be resized... look at gbdfed again

OK, changed font ascent, x-ren and y-resn in properties to 24 instead of 600.

No diff.  Set point size to 12.

OK, use xfontsel to get an idea of sensible parameters.

Still too big --- maybe go back to metafont and try as low res device:
$mf '\mode=epsfast; input MZ7CGint'$ gftopk  MZ7CGint.60gf


open and save with no modifications. Move it to… ~/.fonts/mz/MZ7CGint.bdf

Then:

$mkfontdir$ xset fp rehash
$cat fonts.dir$ xterm -fn -unknown-mz7cgint-medium-r-normal--10-100-60-72-p-60-fontspecific-0


and all good. Note that I had to delete all coloured pixels in char20 (hex) since it was filling up the screen with triangles. Note also that this mode proved a bit small… went and had another look at ftp://ftp.tex.ac.uk/tex-archive/fonts/modes/modes.mf and picked a mode a bit bigger, say about 100dpi…

$mf '\mode=nextscrn; input MZ7CGint'  works pretty well. Font could do with some more leading. Play in font editor… Problem is that we have an 8×8 font in a number of boxes that is not a multiple of 8. What other modes are there… 96 dpi? (atarins) — odd choices of blackened pixels. 120 (onetz)? — odd choices of blackened pixels. 120×144 (epswlo) — odd choices of blackened pixels. 144dpi lasf — odd choices of blackened pixels. 72×120 is epsdrft — nope laserjet 300 dpi — nope hifax 200dpi — looks great, but will font be huge? Yes, it looks huge but works really well. Now, can we downsize it? Now, fontforge can open the bdf file… That means one can make a PostScript font or similar… (maybe one day…) $ sudo apt-get install bdfresize

$bdfresize -f1/2 MZ7CGint.bdf > MZ7CGinthalf.bdf  OK, but not ideal. Problems with cursor not present when on a blank space… How is cursor chosen? Anyway, the threequart(er) size one also looks excellent, since 24 and 28 have 4 as a common factor. http://osr507doc.sco.com/en/GECG/X_Font_ProcAddFn.html The cursor seems to be the empty space drawn in reverse, but it does not work here. See ~/bin/mzterm … heh heh heh.  cat ~/bin/mzterm rxvt -g 88x50 -cr white -pr white -bd blue -fg white -bg black -fn -unknown-mz7int1-medium-r-normal--16-160-72-72-c-240-fontspecific-0 #rxvt -g 88x50 -cr white -pr white -bd blue -fg white -bg black -fn -unknown-mz7cgintt-medium-r-normal--18-63-200-200-p-107-fontspecific-0 -e clearsh #rxvt -cr white -pr white -bd blue -fg white -bg black -fn -unknown-mz7cgint-medium-r-normal--21-75-200-200-p-128-fontspecific-0 -e clearsh #rxvt -cr white -pr white -bd blue -fg white -bg blue -fn -unknown-mz7cgint-medium-r-normal--21-75-200-200-p-128-fontspecific-0 -e clearsh #xterm -sb -leftbar -cr white -bd blue -fg white -bg blue -g 88x50 -fn -unknown-mz7int1-medium-r-normal--16-160-72-72-c-240-fontspecific-0  Still no cursor, though… don’t know why. gdbfed can open the MZ-700 ROM directly as a console font…doofus. Just need to put in an average width… BUT, the encoding is of course all over the shop. Step 1 is to put out first half of the ROM to MZ7int1.ROM Step 2 is to open this in gbdfed (console font) Step 3 is to re-encode correctly: $ mv MZ7int1.bdf MZ7int1_recode.bdf


Then change the encoding number in the file. I can’t be bothered right now. Easiest would be to use the re-encoding table I put into the C file for mz2mf to make the tex font… Done.

OK, play with scale of it using bdfresize — just 2 3 4x for now Done.

OK, these are the better fonts. No need to go via LaTeX. Just note it as possible and move on! Descenders are getting chopped off by the next line, but I don’t really care.

mzterm launches a terminal widow using the font. It is cute to do the white on blue look like the old machine, but directory names don’t look too good…

Translated all glyphs by 2 in Y to try to increase leading.

Copy to ~/.fonts/mz then cd there and mkfontdir etc
_____________________________________________________________________________

And here’s a picture….

\$ xterm -sb -leftbar -cr white -bd blue -fg white -bg blue -g 88x50 -fn -unknown-mz7int1-medium-r-normal--16-160-72-72-c-240-fontspecific-0 &