Text FormattingTEX software adds unwanted spaces and misaligns square brackets on the right

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
EugenioDiLorenzo
Posts: 3
Joined: Mon Dec 15, 2025 5:05 pm

TEX software adds unwanted spaces and misaligns square brackets on the right

Post by EugenioDiLorenzo »

TEX software adds unwanted spaces and misaligns square brackets on the right


In the source: https://sourceforge.net/p/gnucobol/code ... /2-1A.texi
there is the macro: @diagram{Complete GnuCOBOL Program,Complete-Program-Info,Complete-Program-Info,None}
which inserts the file: SYN-Complete-Program-Info.texi
This file contains some dots and ellipses...


The right square brackets are correctly aligned in the source file but are misaligned in the PDF generated by TEX.
Apparently, the right square brackets shift to the right when there is a period . or three periods ... in the line.
TEX software adds unwanted spaces.

This is part of source file: 2-1A.texi that call the macro "diagram" :

@comment *********************************************************************
@comment ** 2.1.17 Program Structure **
@comment *********************************************************************
@page
@newsubsection{Program Structure}
@diagram{Complete GnuCOBOL Program,Complete-Program-Info,Complete-Program-Info,None}



This is the macro:

@comment +-------------------------------------------------------------------+
@comment | MACRO: diagram{title,fileinfo,filetex,note |
@comment | |
@comment | Insert a syntax diagram. Arguments are as follows: |
@comment | title Title of Diagram |
@comment | fileinfo "INFO" Format filename : SYN-<fileinfo>.texi |
@comment | filetex "TeX" Format filename : SYN-<filetex>.texi |
@comment | note Notes filename : NOTE-<note>.texi |
@comment +-------------------------------------------------------------------+
@macro diagram{title,fileinfo,filetex,note}
@ifnottex
@ifset SKELETON
@sp 1
@center =======================================================================
@end ifset
@center \title\ Syntax
@center =======================================================================
@sp 1
@verbatiminclude SYN-\fileinfo\.texi
@include NOTE-\note\.texi
@end ifnottex
@iftex
@cartouche
@smallformat
@center @b{\title\ Syntax}
@end smallformat
@end cartouche
@verbatiminclude SYN-\filetex\.texi
@include NOTE-\note\.texi
@end iftex
@ifnottex
@ifclear SKELETON
@sp 1
@center =======================================================================
@end ifclear
@end ifnottex
@iftex
@ifclear SKELETON
@sp 1
@center ------------------------------------------------------------------------------------------------------------------------
@end ifclear
@end iftex
@end macro


this is the content of file: SYN-Complete-Program-Info.texi where right sqare brackets are vertical aligned:

Code: Select all

 [ IDENTIFICATION DIVISION.                                       ]
   ~~             ~~~~~~~~
   PROGRAM-ID|FUNCTION-ID.  name-1 [ Program-Options ].
   ~~~~~~~~~~ ~~~~~~~~~~~

 [ ENVIRONMENT DIVISION.                                          ]
 [ ~~~~~~~~~~~ ~~~~~~~~                                           ]
 [ CONFIGURATION SECTION.                                         ]
 [ ~~~~~~~~~~~~~ ~~~~~~~                                          ]
 [ SOURCE-COMPUTER.         Compilation-Computer-Specification.   ]
 [ ~~~~~~~~~~~~~~~                                                ]
 [ OBJECT-COMPUTER.         Execution-Computer-Specification.     ]
 [ ~~~~~~~~~~~~~~~                                                ]
 [ REPOSITORY.              Prototype-Specification... .          ]
 [ ~~~~~~~~~~                                                     ]
 [ SPECIAL-NAMES.           Program-Configuration-Specification.  ]
 [ ~~~~~~~~~~~~~                                                  ]
 [ INPUT-OUTPUT SECTION.                                          ]
 [ ~~~~~~~~~~~~ ~~~~~~~                                           ]
 [ FILE-CONTROL.            General-File-Description... .         ]
 [ ~~~~~~~~~~~~                                                   ]
 [ I-O-CONTROL.             File-Buffering-Specification... .     ]
   ~~~~~~~~~~~

 [ DATA DIVISION.                                                 ]
 [ ~~~~~~~~~~~~~                                                  ]
 [ FILE SECTION.            Detailed-File-Description... .        ]
 [ ~~~~~~~~~~~~                                                   ]
 [ WORKING-STORAGE SECTION. Permanent-Data-Definition... .        ]
 [ ~~~~~~~~~~~~~~~ ~~~~~~~                                        ]
 [ LOCAL-STORAGE SECTION.   Temporary-Data-Definition... .        ]
 [ ~~~~~~~~~~~~~ ~~~~~~~                                          ]
 [ LINKAGE SECTION.         Subprogram-Argument-Description... .  ]
 [ ~~~~~~~ ~~~~~~~                                                ]
 [ REPORT SECTION.          Report-Description... .               ]
 [ ~~~~~~ ~~~~~~~                                                 ]
 [ SCREEN SECTION.          Screen-Layout-Definition... .         ]
   ~~~~~~ ~~~~~~~

   PROCEDURE DIVISION [ { USING  Subprogram-Argument...         } ]
   ~~~~~~~~~ ~~~~~~~~ [ { ~~~~~                                 } ]
                      [ { CHAINING Main-Program-Argument...     } ]
                          ~~~~~~~~
                      [   RETURNING identifier-1                 ].
                          ~~~~~~~~~
 [ DECLARATIVES.                ]
 [ ~~~~~~~~~~~~                 ]
 [ Event-Handler-Routine... .   ]
 [ END DECLARATIVES.            ]
   ~~~ ~~~~~~~~~~~~

   General-Program-Logic.

 [ Nested-Subprogram... ]

 [ END PROGRAM|FUNCTION name-1. ]
   ~~~ ~~~~~~~ ~~~~~~~~
   



TEX inserts unwanted spaces after the single dots and after ellipsis;
it's unclear what the rule is, and this causes the right brackets to be misaligned.
See attached image.

How can I tell to TEX do not add spaces after dots and after ellipsis ?
Attachments
PG.png
PG.png (392.86 KiB) Viewed 1423 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10397
Joined: Mon Mar 10, 2008 9:44 pm

Re: TEX software adds unwanted spaces and misaligns square brackets on the right

Post by Stefan Kottwitz »

Hi Eugenio,

welcome to the forum!

I think it's not TeX inserting additional spaces, but that's done by texinfo, which controls whitespace and adds its own punctuation spacing rules. To prevent spacing, you may use {} after a command, like

Code: Select all

@code{OBJECT-COMPUTER}{},
or use @ before punctuation to suppress a space, like

Code: Select all

@code{OBJECT-COMPUTER}@,
Try both at such a place and see if @ or {} helps at that point.

Stefan
LaTeX.org admin
EugenioDiLorenzo
Posts: 3
Joined: Mon Dec 15, 2025 5:05 pm

Re: TEX software adds unwanted spaces and misaligns square brackets on the right

Post by EugenioDiLorenzo »

Hello Stefan,
and thank you so much for your reply. Unfortunately, your suggestion isn't clear to me.
Since I posted the actual code from my TEX document, could you tell me where I should apply your suggestion ?

Something like the following ?
@verbatiminclude SYN-\fileinfo\.texi{}
or
@verbatiminclude SYN-\fileinfo\.texi@

Or should it be placed in the command inside the macro ?
@diagram{Complete GnuCOBOL Program,Complete-Program-Info,Complete-Program-Info,None}{}
or
@diagram{Complete GnuCOBOL Program,Complete-Program-Info,Complete-Program-Info,None}@
Or somewhere else?


PS. Just so you know, the complete document (the GnuCOBOL Programmer's Guide, nearly 1,000 pages) can be found here:
https://sourceforge.net/p/gnucobol/code ... doc/guide/
User avatar
Stefan Kottwitz
Site Admin
Posts: 10397
Joined: Mon Mar 10, 2008 9:44 pm

Re: TEX software adds unwanted spaces and misaligns square brackets on the right

Post by Stefan Kottwitz »

Hi Eugenio,
EugenioDiLorenzo wrote: Fri Dec 19, 2025 7:26 pm Since I posted the actual code from my TEX document
That's not TeX code, it's texinfo code. Do you have a TeX code, possibly converted from texinfo .texi?
EugenioDiLorenzo wrote: Fri Dec 19, 2025 7:26 pmcould you tell me where I should apply your suggestion?
Before the punctuation symbols. I cannot test it for you without a compilable file and information how to convert that to PDF. A simple texinfo call doesn't work here.

Stefan
LaTeX.org admin
EugenioDiLorenzo
Posts: 3
Joined: Mon Dec 15, 2025 5:05 pm

Re: TEX software adds unwanted spaces and misaligns square brackets on the right

Post by EugenioDiLorenzo »

Vincent Coen and I are updating and correcting the GnuCOBOL manual, trying to understand how to proceed by looking at what's in the files.
I won't deny that sometimes we feel like converting everything into a Word or LibreOffice file, with which we'd be more familiar, but for now we insist on keeping everything as is, and we're managing, albeit with difficulty.

Everything we have is on this site:
https://sourceforge.net/p/gnucobol/code ... doc/guide/
I believe they also contain everything necessary, such as the command files for creating PDFs.
Here are also the PDFs created and updated each time.

Unfortunately, as you may have guessed, we don't have the experience to figure out how to fix this annoying behavior on my own.
We'd love our manual to be perfect, even aesthetically.
I'm looking for help on this site, hoping to find someone who can give us the right direction.
I don't need you to run tests for us, but I do need detailed instructions on how to proceed.
Post Reply