Re: groffstudio 0.10.1

2022-03-11 Thread Hans Bezemer via
Dear Tux0r,

Although I use make(1) for compiling my own files, I'm enthusiastic about your 
project.
My coworkers like the opportunities groff gives, but would like a more 
graphical program to work with.
I'll be happy to give your program a try.

Kind regards,

Hans

11 mrt. 2022 19:40:45 Douglas McIlroy :

>> Its main functionality is “calling groff with a number of parameters".
> 
> How might this be or become more than lipstick on a make(1) recipe?
> 
> I imported the windows package and started it. It immediately reported
> that it couldn't find SSL. This smelled bad. What was its intent?
> 
> Finally, I'm used to hearing from real people on this mailing list,
> which is not to say tux0r isn't welcome, merely that I'd like to know
> who it is.
> 
> Doug McIlroy



Re: Use of sed in PDFPIC macro with OpenBSD

2021-12-07 Thread Hans Bezemer
Hi Ralph,

> > awk '/^Page size:/ {print ".nr pdf-wid (p;"$3")"; print ".nr pdf-ht  
> (p;"$5")"}'
> .nr pdf-wid (p;595)
> .nr pdf-ht  (p;842)
> $
Thanks, this helped.
Changed the appropriate lines into:
.  sy pdfinfo @$1 | \
awk '/^Page size:/ {print ".nr pdf-wid (p;"$3")"; \
print ".nr pdf-ht  (p;"$5")"}' \
> /tmp/pdfpic\n[$$]

This seems to work fine.
I've attached a patch file.



Kind regards,

Hans
--- pdfpic.tmac.origin  Tue Dec  7 18:28:07 2021
+++ pdfpic.tmac Tue Dec  7 18:34:15 2021
@@ -84,10 +84,8 @@
 .\" get image dimensions
 .  ec @
 .  sy pdfinfo @$1 | \
-grep "Page *size" | \
-sed -e 's/Page *size: *\\([[:digit:].]*\\) *x *\\([[:digit:].]*\\).*$/\
-.nr pdf-wid (p;\\1)\\n\
-.nr pdf-ht  (p;\\2)/' \
+awk '/^Page size:/ {print ".nr pdf-wid (p;"$3")"; \
+print ".nr pdf-ht  (p;"$5")"}' \
 > /tmp/pdfpic\n[$$]
 .  so /tmp/pdfpic\n[$$]
 .  sy rm /tmp/pdfpic\n[$$]


Snippets

2021-07-24 Thread Hans Bezemer
Dear all,

Recently there have been some discussion on setting up a snippet repository[1].

Would it be a good idea to use the mailinglist to post a snippet and have some
discussion about it before adding it to the (upcoming) repository?

To make it easy to search for snippets in the mailinglist we could agree on
using some labels for instance:
[snippet] [macroset] [extension_] or [standalone]
And maybe some more in the title of the message.

The initial message should for instance contain a short description of the 
snippet and a title.

While thinking about it, why not set up a git repository for the time being and 
upload snippets there?

Just some thoughts I had...

Kind regards,

Hans

[1] https://lists.gnu.org/archive/html/groff/2021-07/msg00039.html 



Re: groff-examples repository

2021-07-14 Thread Hans Bezemer
To have a place where groff examples can be found would be
great!

I would like to add a suggestion.

I've used lilypond frequently to typeset scores.
They have a snippet-repository[1] which I found very useful
at the time.

One of the advantages is that users can submit their own
snippets.

Kind regards,

Hans
[1] https://lsr.di.unimi.it/LSR/html/whatsthis.html

On 21/07/13 09:06AM, Wim Stockman wrote:
> This is fantastic :-).
> 
> 
> Op di 13 jul. 2021 om 04:41 schreef Dave Kemper :
> 
> > On 7/12/21, Thomas Dupond  wrote:
> > > I'm skimming through the archives to try to create such a document
> >
> > Fantastic!
> >
> > > it is taking a lot of time since it goes back to 1999
> >
> > Happily, the entire archives don't need to be scoured at once.  Having
> > something out there in incomplete form is better than having nothing
> > out there; it can always be expanded as you or others have the chance
> > to peruse more of the email archive and find new things.
> >
> > Here are a few that I've found useful at various times.
> >
> > Typesetting arbitrary fractions
> > http://lists.gnu.org/archive/html/groff/2005-11/msg00029.html
> > (with a caveat in
> > http://lists.gnu.org/archive/html/groff/2013-09/msg00022.html)
> >
> > Rotating or reversing characters (PostScript ouptut only)
> > http://lists.gnu.org/archive/html/groff/2000-08/msg00068.html
> >
> > Reflowing text several times to determine an optimum configuration
> > http://lists.gnu.org/archive/html/groff/2008-12/msg6.html
> >
> > Outputting cut marks
> > http://lists.gnu.org/archive/html/groff/2008-12/msg00024.html
> >
> > Command-line utility to show all the potential hyphenation points
> > groff knows for a word
> > http://lists.gnu.org/archive/html/groff/2018-11/msg00023.html
> >
> > and of course the strchr / strrchr macros that kick-started the
> > present discussion
> > http://lists.gnu.org:443/archive/html/groff/2021-06/msg00101.html
> >
> > > I wondered what would be actually eligible to end up in the document.
> > >
> > > I'm currently keeping examples using native groff syntax but I'm
> > > hesitant on including personal macro sets posted to the mailing list.
> >
> > The great thing about volunteering to start a project is you get to
> > dictate its ground rules. :-)
> >
> >



Re: [mom] using chem in mom

2021-06-29 Thread Hans Bezemer
That was easy.

Thanks!
On 21/06/29 11:21AM, Tadziu Hoffmann wrote:
> 
> > But I would like to append arguments after .PS like `CAPTION'
> > and `TARGET'.
> 
>   .PS CAPTION "My chemical structure" TARGET "NoMethane"
>   begin chem
>   CH3
>   bond
>   CH3
>   end
>   .PE
> 
> 
> 



[mom] using chem in mom

2021-06-29 Thread Hans Bezemer
Dear all,

I would like to use chem along with mom.

This:
.cstart
CH3
bond
CH3
.cend

Results in:
.PS

.PE
After preprocessing it with chem.

But I would like to append arguments after .PS like `CAPTION'
and `TARGET'.

An option could be to add a marker above the chem code:
\# ChemPic: CAPTION "My chemical structure" TARGET
"NoMethane" and use sed or awk to append everything after the ":" to .PS
But is there a more straightforward option to use chem with
mom?

Kind regards,

Hans



Re: (A possible) way to change the background color of pdf

2021-06-15 Thread Hans Bezemer
On 21/06/15 03:14PM, Tadziu Hoffmann wrote:
> 
> > I want to have a black background with green text for
> > my slides.
> > 
> > If I'm correct this can't be set within groff.
> 
> You can draw a filled polygon (rectangle) using \D'P ...'
> covering the whole page at the beginning of each page,
> before outputting any text.  Example:
> 
> 
> .\" a4 land
> .\" 
> .nr PL 21.0c \" A4 landscape height
> .nr PW 29.7c \" A4 landscape width
> .pl \n(PLu
> .po 2c
> .ll \n(PWu-\n(.ou-\n(.ou
> .gcolor green
> .\" 
> .\" set up a separate environment for headers and footers
> .\" to avoid interference with the running text
> .ev 1
> .vs 0
> .lt \n(PWu-\n(.ou-\n(.ou
> .fcolor black
> .gcolor yellow
> .ev
> .\" 
> .de BP
> .ev 1
> \Z'\h'-\\n(.ou'\D'P 0 \\n(PLu \\n(PWu 0 0 -\\n(PLu''
> .sp |2c
> .ev
> ..
> .de EP
> .ev 1
> .sp |\\n(PLu-1.5c
> .tl '\\n[year]/\\n[mo]/\\n[dy]''\\n%'
> .bp
> .ev
> ..
> .wh 0 BP
> .wh -3c EP
> .\" 
> Hello, world!
> 
> 

Dear Tadziu and Deri,

I've tried to build the dev-* branch but I'll need to look
into that later, had some errors running make.

Tadziu's code works smooth so will use that for now, thanks.

Kind regards,

Hans



Re: (A possible) way to change the background color of pdf

2021-06-15 Thread Hans Bezemer
On 21/06/15 11:01AM, Deri wrote:
> On Tuesday, 15 June 2021 10:29:37 BST Hans Bezemer wrote:
> > Dear all,
> > 
> > I want to have a black background with green text for my
> > slides.
> > 
> > If I'm correct this can't be set within groff.
> 
> Hi Hans,
> 
> In the message https://lists.gnu.org/archive/html/groff/2021-04/msg0.html 
> a way of 
> setting the paper colour in pdf files is described. Currently you need to 
> checkout the gropdf-
> boxes branch of the git repository to use it.
> 
> Cheers 
> 
> Deri
> 
Hi Deri,

Ahh, I missed your post because I used `color' instead of
`colour' while searching the mailinglist.

Will check the branch out, thanks for the pointer.

Cheers,

Hans



(A possible) way to change the background color of pdf

2021-06-15 Thread Hans Bezemer
Dear all,

I want to have a black background with green text for my
slides.

If I'm correct this can't be set within groff.

I've created a script to post process the pdf to add the
desired background color.

This is my sample document:
cat GreenText.groff

.gcolor green
Green text
.bp
More Green text on page 2
.bp
Green on 3
.bp
Green on 4
.bp
Green on 5
.bp
Green on 6
.bp
Green on 7
.bp
Green on 8
.bp
Green on 9
.bp
Green on 10

The scripts adds a background color per page (It doesn't
seem to be able to add it on a multipage pdf directly) and
the separate pages with the added background color are
merged.

cat ConvertBackground.sh  

#!/bin/sh
# Script to convert background of pdf to color specified by $2
# Get the name without extension
NAME=$(echo $1 | cut -d "." -f 1 )
# Get the number of pages
PAGES=$(pdfinfo $1 | grep Pages | rev | cut -d " " -f 1 | rev)
# Get the max number of pages from number of pages
DIGMAX=$(echo -n $PAGES | wc -c )
# Convert page by page and making sure that if i is > 10 the numbering of the 
temp
# files are still correct.
for i in $(seq 1 $PAGES)
do
j=$(($i-1))
DIGI=$(echo -n $i | wc -c)
DIFFDIG=$(($DIGMAX-$DIGI))
for k in $(seq 1 $DIFFDIG)
do
ZEROI="${ZEROI}0"
done
convert -density 300 $1[$j] -background $2 -flatten -quality 100 
Temp${NAME}${ZEROI}${i}.pdf
unset ZEROI
done
# Merge the temp pdfs to one.
pdfunite Temp${NAME}*.pdf ${NAME}${2}.pdf
# Delete temp files.
rm -fv Temp${NAME}*.pdf
#End Of File

Please let me know if there are better solutions available
but this seems to work for now.

Kind regards,

Hans



Re: [mom] Using LIST with DOCTYPE SLIDES

2021-06-13 Thread Hans Bezemer
Hi Oliver,

LIST OFF did the trick.
Thank you.
I thing PRINTSTYLE isn't needed for slides, I think it's
part of the macro SLIDES.

Regards,

Hans
On 21/06/13 08:24PM, Oliver Corff wrote:
> Hi Hans,
> 
> I understand from mom's documentation that you are required to have a
> .PRINTSTYLE.
> 
> Then, I finished your example with .LIST OFF after the "Bye" and it
> compiles, probably as intended, while throwing the error message
> 
> slide.mom:5: can't transparently output node at top level
> 
> Here my trial version:
> 
> .\" TITLE "Trial"
> .\" AUTHOR "Hans Bezemer"
> .\" PRINTSTYLE TYPESET
> .DOCTYPE SLIDES
> .START
> .HEADING 1 "Heading 1!"
> .LIST
> .ITEM
> Hello
> .ITEM
> Bye
> .LIST OFF
> 
> See attachment for result.
> 
> Best regards,
> 
> Oliver.
> 
> 
> On 13/06/2021 19:14, Hans Bezemer wrote:
> > Dear all,
> > 
> > I would like to use LIST within DOCTYPE SLIDES in mom, but
> > when doing so it doesn't show.
> > 
> > Also trying to set QUAD to LEFT doesn't seem to work.
> > Maybe I'm missing the obvious.
> > 
> > Here's a minimal code:
> > 
> > .DOCTYPE SLIDES
> > \#.PRINTSTYLE TYPESET
> > \#.DOCTYPE DEFAULT
> > 
> > .START
> > .HEADING 1 "Heading 1!"
> > .LIST
> > .ITEM
> > Hello
> > .ITEM
> > Bye
> > 
> > Kind regards,
> > 
> > Hans
> > 





[mom] Using LIST with DOCTYPE SLIDES

2021-06-13 Thread Hans Bezemer
Dear all,

I would like to use LIST within DOCTYPE SLIDES in mom, but
when doing so it doesn't show.

Also trying to set QUAD to LEFT doesn't seem to work.
Maybe I'm missing the obvious.

Here's a minimal code:

.DOCTYPE SLIDES 
\#.PRINTSTYLE TYPESET
\#.DOCTYPE DEFAULT

.START
.HEADING 1 "Heading 1!"
.LIST
.ITEM
Hello
.ITEM
Bye

Kind regards,

Hans



Re: AW: Macro's for making an exam.

2021-06-09 Thread Hans Bezemer
Thanks for all the suggests.
This is indeed what I want.
I will expand the `answer' part, because sometimes students have to draw stuff 
on a grid or into a given graph,
but I can continue from here.

Regards,

Hans


On 21/06/09 11:46PM, Keith Marshall wrote:
> Apologies for any confusion, which this may have caused:
> 
> On 09/06/2021 23:28, I wrote:
> > he should have:
> > 
> >.de SOLUTION
> >.   if (\\n[s] == 0) .ig SOLEND
> >.   br
> >..
> >.de ENDSOL
> >.   \" Any clean-up required, at end of solution.
> >..
> 
> Of course, my ENDSOL macro should, rather, have been called SOLEND:
> 
>.de SOLEND
>.   \" Any clean-up required, at end of solution.
>..
> 
> -- 
> Regards,
> Keith



Re: Macro's for making an exam.

2021-06-09 Thread Hans Bezemer
Dear all,

I'm able to toggle a piece of code on or off with:
.nr s 0 \# toggling answers on/off [0:1]
.if (\n[s] == 0) .ig ++
.br
Text
.++

But when I try to put it in a macro it doesn't work:
.nr s 0
.de SOLUTION
.if (\n[s] == 0) .ig ++
.br
..
.de SOLEND
.++
..

.SOLUTION
Text
.SOLEND

I've checked the groff manual a few times, but I can't really figure out
what's going wrong.

Do I somehow need to escape the .ig command in the macro?
I also tried to make a similar example using .box instead of .ig and it 
behaved the same, thus in a macro it didn't work.

Kind regards,

Hans


On 21/06/07 09:07PM, Hans Bezemer wrote:
> Dear Oliver,
> 
> Thanks for the detailed answer.
> 
> I will take a look at UTP (have downloaded it).
> Will give a heads up when I have a working example.
> 
> Kind regards,
> 
> Hans
> 
> On 21/06/07 08:04PM, Oliver Corff wrote:
> > Hi Hans,
> > 
> > That sounds like an interesting challenge to learn groff, especially
> > after being familiar with LaTeX.
> > 
> > Groff is certainly more terse as a language and has some tricky points
> > when defining macros and nested commands (you'll need multiple escapes)
> > but the basics are easy to grasp and the language is quite forgiving in
> > the sense that faulty code won't crash anything. There are plenty of
> > warning messages issued by groff if things do not go as expected, and
> > the best proof that something went fundamentally wrong is a blank sheet
> > of output.
> > 
> > If you have defined "building blocks" for the composition of your exam
> > sheets you can store them in external files which you call with
> > 
> > .so myfile.roff
> > 
> > (.so mnemonic: source file). Don't forget piping everything via soelim
> > to the groff processor if you do that.
> > 
> > That helps visually declobber the file where you keep your macros.
> > 
> > Conditionals are called with
> > 
> > .if cond anything
> > 
> > (see groff(7) for a summary list of all requests ("Request Short
> > Reference").
> > 
> > A detailed overview of conditionals can be found, e.g., on p. 46 of the
> > Nroff/Troff User's Manual that comes with Heirloom Documentation Tools
> > (I just happen to find this one first); a thorough discussion of
> > "Conditional Execution" can be found on pp. 278 of Unix Text Processing
> > by Dale Dougherty and Tim O'Reilly (the book is better known as UTP,
> > though).
> > 
> > Your question if you have to run groff twice if you want to present
> > collected information on the first page: in general, yes. That is, as
> > long as you deal with the traditional macro packages (that is also the
> > reason why with the default  commands of the -ms macros a table of
> > contents is placed at the end of the book, not the beginning, if no
> > measure is taken). However, the mom macro package and its wrapper
> > pdfmom, will help you place collected material near the beginning of the
> > document as pdfmom takes care of the necessary number of steps to
> > compile a complete document.
> > 
> > Hope that helps,
> > 
> > Oliver.
> > 
> > 
> > 
> > On 07/06/2021 15:37, Hans Bezemer wrote:
> > > Dear all,
> > > 
> > > I've started working with groff recently.
> > > Being a teacher I have three types of documents I mainly create:
> > > 1. Articles;
> > > 2. Presentations;
> > > 3. Exams.
> > > 
> > > I'm using LaTeX (article, beamer, exam) for those documents at the moment.
> > > 
> > > To get my feet wet with groff I want to create a set of macros for making 
> > > a test.
> > > 
> > > Goal is to make it compatible with the mm, ms and mom macrosets.
> > > The macro's have to be able to print the number of questions, the sum of 
> > > the points when called for.
> > > the format of question is simple and should be:
> > >   
> > > whereas the  are placed in the margin.
> > > 
> > > I would like to be able to toggle between printing the solution or space 
> > > to answer the question, thus
> > > something along these lines (with arbitrary choosen macronames):
> > > 
> > > 
> > > Introduction on the question
> > > 
> > > .Q1 2
> > > .\" 2 is the number of points
> > > Question...
> > > .Q2
> > > .A1
> > > .\" start of answer block
> > > All sorts of formatting to use to answer the questi

Re: Macro's for making an exam.

2021-06-07 Thread Hans Bezemer
Dear Oliver,

Thanks for the detailed answer.

I will take a look at UTP (have downloaded it).
Will give a heads up when I have a working example.

Kind regards,

Hans

On 21/06/07 08:04PM, Oliver Corff wrote:
> Hi Hans,
> 
> That sounds like an interesting challenge to learn groff, especially
> after being familiar with LaTeX.
> 
> Groff is certainly more terse as a language and has some tricky points
> when defining macros and nested commands (you'll need multiple escapes)
> but the basics are easy to grasp and the language is quite forgiving in
> the sense that faulty code won't crash anything. There are plenty of
> warning messages issued by groff if things do not go as expected, and
> the best proof that something went fundamentally wrong is a blank sheet
> of output.
> 
> If you have defined "building blocks" for the composition of your exam
> sheets you can store them in external files which you call with
> 
> .so myfile.roff
> 
> (.so mnemonic: source file). Don't forget piping everything via soelim
> to the groff processor if you do that.
> 
> That helps visually declobber the file where you keep your macros.
> 
> Conditionals are called with
> 
> .if cond anything
> 
> (see groff(7) for a summary list of all requests ("Request Short
> Reference").
> 
> A detailed overview of conditionals can be found, e.g., on p. 46 of the
> Nroff/Troff User's Manual that comes with Heirloom Documentation Tools
> (I just happen to find this one first); a thorough discussion of
> "Conditional Execution" can be found on pp. 278 of Unix Text Processing
> by Dale Dougherty and Tim O'Reilly (the book is better known as UTP,
> though).
> 
> Your question if you have to run groff twice if you want to present
> collected information on the first page: in general, yes. That is, as
> long as you deal with the traditional macro packages (that is also the
> reason why with the default  commands of the -ms macros a table of
> contents is placed at the end of the book, not the beginning, if no
> measure is taken). However, the mom macro package and its wrapper
> pdfmom, will help you place collected material near the beginning of the
> document as pdfmom takes care of the necessary number of steps to
> compile a complete document.
> 
> Hope that helps,
> 
> Oliver.
> 
> 
> 
> On 07/06/2021 15:37, Hans Bezemer wrote:
> > Dear all,
> > 
> > I've started working with groff recently.
> > Being a teacher I have three types of documents I mainly create:
> > 1. Articles;
> > 2. Presentations;
> > 3. Exams.
> > 
> > I'm using LaTeX (article, beamer, exam) for those documents at the moment.
> > 
> > To get my feet wet with groff I want to create a set of macros for making a 
> > test.
> > 
> > Goal is to make it compatible with the mm, ms and mom macrosets.
> > The macro's have to be able to print the number of questions, the sum of 
> > the points when called for.
> > the format of question is simple and should be:
> > 
> > whereas the  are placed in the margin.
> > 
> > I would like to be able to toggle between printing the solution or space to 
> > answer the question, thus
> > something along these lines (with arbitrary choosen macronames):
> > 
> > 
> > Introduction on the question
> > 
> > .Q1 2
> > .\" 2 is the number of points
> > Question...
> > .Q2
> > .A1
> > .\" start of answer block
> > All sorts of formatting to use to answer the question:
> > lines, grid, drawing.
> > .A2
> > .S1
> > .\"start of solution block
> > Block to explain the answer to the question
> > .S2
> > 
> > And when a variable `a' is set 0 then A1/A2 block is printed
> > and S1/2 block is ignored.
> > When `a' is 1 then the other way around.
> > 
> > I would like to get a few pointers.
> > What would be a good way to conditional ignore a specific block of text?
> > It could be done with sed of course, letting it delete anything between and 
> > including S1 and S2 before piping the text into groff, but I would like to 
> > do it within groff.
> > 
> > Secondly, I want to put the sum of the points and number of questions on 
> > the first page.
> > Is it needed to run groff twice to get does values?
> > 
> > Thanks in advance.
> > 
> > Kind regards,
> > 
> > Hans Bezemer
> > 
> 



Macro's for making an exam.

2021-06-07 Thread Hans Bezemer
Dear all,

I've started working with groff recently.
Being a teacher I have three types of documents I mainly create:
1. Articles;
2. Presentations;
3. Exams.

I'm using LaTeX (article, beamer, exam) for those documents at the moment.

To get my feet wet with groff I want to create a set of macros for making a 
test.

Goal is to make it compatible with the mm, ms and mom macrosets.
The macro's have to be able to print the number of questions, the sum of the 
points when called for.
the format of question is simple and should be:

whereas the  are placed in the margin.

I would like to be able to toggle between printing the solution or space to 
answer the question, thus
something along these lines (with arbitrary choosen macronames):


Introduction on the question 

.Q1 2 
.\" 2 is the number of points
Question...
.Q2
.A1 
.\" start of answer block
All sorts of formatting to use to answer the question:
lines, grid, drawing.
.A2
.S1 
.\"start of solution block
Block to explain the answer to the question
.S2

And when a variable `a' is set 0 then A1/A2 block is printed
and S1/2 block is ignored. 
When `a' is 1 then the other way around.

I would like to get a few pointers.
What would be a good way to conditional ignore a specific block of text?
It could be done with sed of course, letting it delete anything between and 
including S1 and S2 before piping the text into groff, but I would like to do 
it within groff.

Secondly, I want to put the sum of the points and number of questions on the 
first page.
Is it needed to run groff twice to get does values?
 
Thanks in advance.

Kind regards,

Hans Bezemer