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



Slight alteration to back bond of chem.pic

2025-03-01 Thread Hans Bezemer via GNU roff typesetting system discussion
Dear members,

I'm using chem frequently for making tests for school.

Although it's a bit hidden in the manual but a neat feature of chem
is being able to create back and front bonds.
The front bond is formed by an arrowhead (clever solution).
The back bond is created of spaced lines.
With a slight alteration this can be converted into
a dashed triangle / wedge.
Although the several textbooks / websites I consulted use different back bonds
(some dashed and tapered, some just a single dotted bond),
the dashed wedge seems the most common.

Here's the diff:
cat << EOF > Chem.diff
--- chem.pic2024-05-09 21:59:57.902746496 +0200
+++ /usr/share/groff/1.23.0/pic/chem.pic2025-03-01 16:21:28.138092943 
+0100
@@ -70,7 +70,7 @@
nx = -dy * .02 / norm
for i = 1 to n-1 do {
XZ: i/n 
-   line from XZ + (nx,ny) to XZ - (nx,ny)
+   line from XZ + (nx*i/n,ny*i/n) to XZ - (nx*i/n,ny*i/n)
}
move to V2
 }
EOF

A simple example (added as attachment):

cat << EOF | chem | pic | groff -Tpdf > Sample.pdf
.cstart
H
bond down
C
back bond length 0.08 down from C
F
front bond length 0.3 125 from C
Cl
front bond length 0.3 -125  from C
Br
#F
.cend
EOF

Could this to be considered as a (small but) useful alteration?

Kind regards,

Hans


Sample.pdf
Description: Adobe PDF document


Re: Slight alteration to back bond of chem.pic

2025-03-04 Thread Hans Bezemer via GNU roff typesetting system discussion
Dear Norwid,

Thank you for the reply.
As for comment 1, you are entirely right.
My example was just fast mock up to show the difference.

As for comment 2, my (lack of) my English vocabulaire comes into play.
Based on the overview given on stack exchange, I've created different bond 
types.[1]

I've made a sample document with first showing the different bonds
in 45 degree steps.
I've also tried to recreate the examples you send.

Would you agree on the names given now?
What else should be added / altered?

Kind regards,

Hans




[1] 
https://chemistry.stackexchange.com/questions/174299/different-types-of-bond-representations

On Sat, Mar 01, 2025 at 07:00:03PM +0100, Norwid Behrnd wrote:
> Dear Hans,
> 
> a few comments:
> 
> - Do you need to represent all four substituents around the stereogenic 
> center?
> 
>   Because so often, hydrogen if bound to carbon is implicit in the formulae,
>   without ambiguity.  And if all four substitutents around the carbon need to
>   be shown -- as to introduce / train / test usage of CIP rules -- two
>   substituents and the (implicit) carbon in one layer, one substituent above,
>   the fourth below the drawing plane could simplify the drawing. Except when
>   up to _explain_ Fischer formulae for carbohydrates.
> 
> - Re tapered bonds/dashed bonds.
> 
>   Do you refer to _dashed bonds_ on one, and a _bold but non-tapered bond_ on
>   an other stereogenic center of the same molecule?  If so, this describes the
>   two substitutents only in _trans_ relationship to each other, because of
>   lack for further evidence about their absolute configuration.  Or to
>   describe a mixture of diastereomers, which could be for instance a 1:3 ratio
>   of (R,R)- and (S,S)-tartaric acid, or a 1:1 racemate -- vague.
> 
>   _Dashed_ sometimes is misused instead of _hashed_ (and opposite to the bold
>   wedge).  However _dashed_ (and even more so, _dotted_ lines) typically
>   symbolize bonds weaker than a typical covalent single bond, between hydrogen
>   bond donors and acceptors.
> 
> It is up to you if you use a molecule editor with subsequent export of an
> image (an old open access review: https://www.gunda.hu/dprogs/), or construct
> the  structures. The later approach is a bit of a niche (as seen for instance
> around chemfig for LaTeX e.g., https://doi.org/10.1186/1758-2946-4-24) and 
> less
> quick to change and adjust _manually_ if needed (cf. Table I in Brecher's
> compilation of guidelines, https://doi.org/10.1351/pac200880020277).
> 
> Kind regards,
> 
> Norwid




Chem.pdf
Description: Adobe PDF document
#! /usr/bin/env perl

# chem - a groff preprocessor for producing chemical structure diagrams

my $copyright = 'Copyright (C) 2006-2014, 2022'
. ' Free Software Foundation, Inc.';
# Written by Bernd Warken .

# This file is part of 'chem', which is part of 'groff'.

# 'groff' is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License (GPL) version 2 as
# published by the Free Software Foundation.

# 'groff' is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

# The GPL2 license text is available in the internet at
# .


# settings


my $chem_version = '1.0.6';
my $groff_version = 'DEVELOPMENT';

require v5.6;



# begin


use warnings;
use strict;
use Math::Trig;

# for catfile()
use File::Spec;

# $Bin is the directory where this script is located
use FindBin;

my $chem;
my $File_chem_pic;

my $is_in_source_tree;
{
  $is_in_source_tree = 1 if '1.23.0' eq '@' . 'VERSION' . '@';
}

my %makevar;

if ($is_in_source_tree) {
  my $chem_dir = $FindBin::Bin;
  $makevar{'G'} = '';
  $File_chem_pic = File::Spec->catfile($chem_dir, 'chem.pic');
  $chem = 'chem';
} else {
  $groff_version = '1.23.0';
  $makevar{'G'} = '';
  $makevar{'PICDIR'} = '/usr/share/groff/1.23.0/pic';
  $File_chem_pic = File::Spec->catfile($makevar{'PICDIR'}, 'chem.pic');
  $chem = $makevar{'G'} . 'chem';
}



# check the parameters


if (@ARGV) {
  # process any FOO=bar switches
  # eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift;
  my @filespec = ();
  my $dbl_minus;
  my $wrong;
  foreach (@ARGV) {
next unless $_;
if (/=/) {
  # ignore FOO=bar switches
  push @filespec, $_ if -f;
  next;
}
if ($dbl_minus) {
  if (-f $_) {
push @filespec, $

Re: Slight alteration to back bond of chem.pic

2025-03-04 Thread Hans Bezemer via GNU roff typesetting system discussion
Dear Doug and others,

I'm sorry. I added the altered scripts as attachment but
didn't realised that this will be added as text to the mail.
Will keep it in mind for a next time.

Kind regards,

Hans
On Tue, Mar 04, 2025 at 09:56:58AM -0500, Douglas McIlroy wrote:
> Please don't post huge programs (in this case 1500 lines) as email text.
>  For those of us who subscribe to the groff digest, it's a pain to scroll
> past such monsters to see the remaining messages. Big documents are best
> relegated to attachments, which readers who need them can fetch from the
> mailing-list. website.
> 
> Thanks,
> Doug



Re: Slight alteration to back bond of chem.pic

2025-03-11 Thread Hans Bezemer via GNU roff typesetting system discussion
Dear Norwid,


On Wed, Mar 05, 2025 at 06:29:32PM +0100, Norwid Behrnd wrote:
> Dear Hans
> 
> I'm able to locally replicate and compile the examples shared by you.  Are the
> names of the bond types preliminary only?

Yes they are. Maybe a mere descriptive name would be more appropiate:
- dashed for what's now called `racemic'
- wdashed for what's now called 'back' (and leave back unaltered, see comment 
below)
- rwdashed for what's now called 'rback'

What would you prefer?

>  For instance `racemic` for a bond
> which is `down` (relative to an other marked as `up`, but in absence of R/S
> assignments) could be improved.

I think that it is up to the user to use bonds as see fit. 
It would complicate matters to supply rules on when and how a bond is used.

>  However, CSTR 122 uses `down` already as an
> alternative to indicate an angle of 180 degrees -- using the same string twice
> as keywords in different spot might derail chem or groff.

The only thing that is added are macro's for new bonds (which are modifications
of existings bond macro's). So the use of `down' is not altered.

>  Why a `back` and an
> additional `rback`?

Mere practical reasons: sometimes it is easier to start with the substituent:

Cl
rback 45
C

and so on.

  In the "test star pattterns", is `Y` meant to be a
> representative of the stereogenic centre, and `X` a substituent?

Yes. Just to show how a certain bond looks under a certain angle.
(Which is still far from being perfect as you rightly observe.)

>  Is the > overarching aim to modernize both chem as well as CSTR 122/its 
> documentation
> further?

No, I just started tinkering with chem and chem.pic because I needed a wedged 
dashed bond.
I think there's even a more simple solution, which gives the individual user the
possibility to create his own bonds to his liking.

Changing this line:
if ($Words[0] =~ /^(double|triple|front|back)$/ &&
 in chem into:
if ($Words[0] =~ /^[a-z]/ &&
would give the opportunity to source your own bonds and leave chem.pic
unaltered. 

> 
> Prior to the addition of new features, depending an either horizontal, or
> diagonal alignment, the bonds lengths in the six-pointed stars vary.  The
> wider width of the wedged bonds vary, too.  What defines the start / end point
> of a wavy bond seems to differ in comparison with plain single bonds; at 
> times,
> the resulting depiction appears "off centred".  This is both surprising, and
> unexpected.

Yes, you're right. This has to be adressed. 
>From what I see, the two main reasons why this happens are:
1. A bond is connected to one of the eight compass points.
   The distance from the compass points to the text of the atom or group
   differs somewhat from point to point;
2. The way dashed and wavy bonds are drawn / calculated.

I don't have a solution for it yet, but I'm pondering over it.
Suggestions are more then welcome.

> 
> Can the bold bond's use be edited to the result of a more "hugging" connection
> with a ring, i.e. without a gap this much noticeable?

I will take a look at this.

>   In the .zip archive is
> an example how e.g., ChemDraw presents such a structure.
> 
> Kind regards,
> 
> Norwid

Kind regards,

Hans



Re: On bonds, arrows and space, was: Slight alteration to back bond of chem.pic

2025-03-13 Thread Hans Bezemer via GNU roff typesetting system discussion
- Forwarded message from Hans Bezemer  -

Date: Fri, 14 Mar 2025 07:14:17 +0100
From: Hans Bezemer 
To: Norwid Behrnd 
Subject: Re: On bonds, arrows and space, was: Slight alteration to back bond
 of chem.pic

Dear Norwid,

Using your ChemDraw example document as a reference I've made up the 
following list of things that are needed to recreate your document
using chem / chem.pic.

1. Bonds in noncyclic molecules
This is mostly done by adding new bonds to chem.pic. 
Most of the bonds were created over the past weeks put need
some refinement.

2. Bonds in cyclic molecules
This is a bit more tricky because of the mechanism of how
the rings are created.
>From what I understand now, a ring is created in the chem script
with all single bonds and extra bonds (double / triple) are
added later if needed.
I've managed to create a dashed double bond, so will move
on from there.

3. Space and arrows
To (more) easily create chemical equations using structural formulas
it would be convenient to have various arrows available, along
with the option to insert white space.
Arrows and space can use the same mechanism as bonds, so
I think something along the lines of:
-> carrow right from
<- carrow
<=> carrow
and so on.

I've added a `c' to the word arrow (from `c'hem) to differentiate 
from the arrow command from pic.

Drawing arcs for reaction mechanisms are fairly easy done by
using pic directly, so I think there's no need for chem alternative
for that.

Is this list complete?

I'll start with the noncyclic bonds, arrows and spaces first.

On a side note:
I use eqn when using formulas:
.EQ
gfont R
2HCl ~+~ 2Na ~\[->]~ NaCl ~+~ H sub 2
.EN

Kind regards,

Hans


On Mon, Mar 10, 2025 at 03:31:01PM +0100, Norwid Behrnd wrote:
> Dear Hans
> 
> On Thu, 6 Mar 2025 08:34:13 +0100
> Hans Bezemer via GNU roff typesetting system discussion  wrote:
>  
> > Yes they are. Maybe a mere descriptive name would be more appropiate:
> > - dashed for what's now called `racemic'
> > - wdashed for what's now called 'back' (and leave back unaltered, see 
> > comment below)
> > - rwdashed for what's now called 'rback'
> > 
> > What would you prefer?
> 
> To me, these names (proposal by March 6th) are better -- since easier to
> recall -- than the ones initially proposed by March 4th.
> 
> [> ...]
> 
> > >  Why a `back` and an
> > > additional `rback`?  
> > 
> > Mere practical reasons: sometimes it is easier to start with the 
> > substituent:
> 
> After more familiarization with groff chem on my side, this makes sense now.
> 
> [> ...]
> 
> > 
> > No, I just started tinkering with chem and chem.pic because I needed a 
> > wedged dashed bond.
> > I think there's even a more simple solution, which gives the individual 
> > user the
> > possibility to create his own bonds to his liking.
> > 
> > Changing this line:
> > if ($Words[0] =~ /^(double|triple|front|back)$/ &&
> >  in chem into:
> > if ($Words[0] =~ /^[a-z]/ &&
> > would give the opportunity to source your own bonds and leave chem.pic
> > unaltered. 
> 
> I used this as a point of entry to add a new bond, dashed double (cf. attached
> zip archive) dubbed here as `ddouble`.  While preliminary, within the daisies,
> it is somewhat functional.  Within cycles (second example), the approach fails
> -- my bad, likely because I don't yet understand fully the ring function.  In
> the MWE shared, this part of the source code still is in the original form.
> 
> An other additional bond type could be a bold double bond (`bdouble`?), for
> later, and maybe a few arrows and hooks -- for comparison, I add a .png (at 
> 300
> dpi resolution) and .pdf of ChemDraw using the ACS1996 style puts on the
> paper.  The implicit(?) unit of length in groff's chem is inch, isn't it?
> 
> Kind regards,
> 
> Norwid



- End forwarded message -