noweb icon indicating copy to clipboard operation
noweb copied to clipboard

`[[--opt]]` typesets to `-opt` (drops one dash) with T1 font encoding

Open dbosk opened this issue 1 year ago • 10 comments

See -edit and --edit: image

The code for the image:

The course responsible must then generate the sign-up sheet.
This is done by running the following command.
\begin{minted}{bash}
nytid signupsheets generate prg[im]24 --edit
\end{minted}
The [[--edit]] option opens the generated sign-up sheet (or sheets in our case, 

Not sure this is expected, I kind of expect [[...]] to be close to verbatim (exception being chunk names) considering I quote code with it.

dbosk avatar May 20 '24 11:05 dbosk

I can add that it's the same in code chunks, not just quoted code.

<<script.sh>>=
cmd --arg
@

Here --arg would also be typeset as -arg.

dbosk avatar May 20 '24 13:05 dbosk

>> (when not part of a chunk) is typeset as », but > is typeset as >. Not sure if that's intended. I would be fine with » if > would be more similar. (I'm writing shell scripts at the moment.)

dbosk avatar May 20 '24 13:05 dbosk

I can't duplicate the fault.

Please send a complete example plus the weave command you used. t.nw.txt t.pdf

nrnrnr avatar May 20 '24 16:05 nrnrnr

Sorry for that, experimented a bit. Here is a MWE, test.nw:

\documentclass{article}
\usepackage[utf8]{inputenc}
%\usepackage[T1]{fontenc}
\usepackage{noweb}

\begin{document}
This is a test to see how [[--opt]] is typeset.
<<script.sh>>=
echo "Hello, world!" >> /tmp/hello.txt
echo --opt
@
\end{document}

Weaved using noweave -delay test.nw > test.tex && pdflatex test.tex.

Got it down to the fontenc package. Whenever the fontenc line is uncommented, the problem occurs.

image

image

I use \usepackage[T1]{fontenc} to get the Swedish letters å, ä, ö correct in PDFs (when selecting and copying them from the PDF they're actually the letters, without T1 you can't copy the text).

dbosk avatar May 21 '24 07:05 dbosk

Added But how is >> now, and > >? before \end{document}: image image

dbosk avatar May 21 '24 07:05 dbosk

But in maths \(a > b\) works?: image

dbosk avatar May 21 '24 07:05 dbosk

Did some more experiments.

Seems like I don't need \usepackage[T1]{fontenc} anymore for Swedish. ~~So I can just remove that line and solve my problem.~~ (See below.)

If I use xelatex instead, everything just works:

\documentclass{article}
\usepackage{noweb}

\begin{document}
This is a test to see how [[--opt]] is typeset.
<<script.sh>>=
echo "Hello, world!" >> /tmp/hello.txt
echo --opt
@

But how is >> now, and > >?
But in maths \(a > b\) works?

What about å, ä and ö?
\end{document}

Weave using noweave -delay test.nw > test.tex && xelatex test.tex produces image

dbosk avatar May 21 '24 08:05 dbosk

Turns out I need the T1 font encoding for other things. (I used other fonts in my original document.) image image

~~XeLaTeX didn't help here. Gives the same horrible font as in the top example, just without the upside-down symbols. But still the guillemets for >>.~~ Works with XeLaTeX after setting fonts correctly.

image

dbosk avatar May 21 '24 08:05 dbosk

The only issue I encounter with XeLaTeX is that I can't use [[...]] in section headings. Might be due to the fonts. I'll continue experimenting.

dbosk avatar May 21 '24 10:05 dbosk

If you are using Unicode, XeLaTeX is definitely the way to go.

nrnrnr avatar May 21 '24 18:05 nrnrnr