jspitz / covington

Maintenance of the covington LaTeX package
9 stars 0 forks source link

Using \[tri|di]gloss outside of example environment breaks fontstyle #13

Closed Marcool04 closed 1 year ago

Marcool04 commented 1 year ago

Hi there,

First of all, thank you for this very useful package. I believe I have found a slight issue with the behaviour of font styling. Please consider the following MWE:

\NeedsTeXFormat{LaTeX2e}
\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[TS1,T1]{fontenc}

\usepackage{covington}
\renewcommand{\glosslineone}{\normalfont\itshape}
\renewcommand{\glosslinetwo}{\footnotesize\sffamily}
\renewcommand{\glosslinethree}{\footnotesize\sffamily}

\usepackage{hyperref}

\begin{document}

  \trigloss[fsii={\itshape}]{building}
           {build -ing}
           {gloss GRAM}
           {translation}

  \begin{example}
    \digloss{Word}
            {gloss}
            {translation}
  \end{example}

\end{document}

image

Notice that the word "gloss" in the second interlinear is NOT in sans font as expected. I have determined that this is caused by the fact that the previous \trigloss is outside of the example environment. This may seem "wrong" maybe, but in the case where I was using it, I didn't want a number nor any kind of specific environment around this example, and so typed it like this. But then, the formatting which I had applied to the glosses in the preamble are broken. Compare to this example which behaves as expected:

\NeedsTeXFormat{LaTeX2e}
\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[TS1,T1]{fontenc}

\usepackage{covington}
\renewcommand{\glosslineone}{\normalfont\itshape}
\renewcommand{\glosslinetwo}{\footnotesize\sffamily}
\renewcommand{\glosslinethree}{\footnotesize\sffamily}

\usepackage{hyperref}

\begin{document}
  \begin{example}
  \trigloss[fsii={\itshape}]{building}
           {build -ing}
           {gloss GRAM}
           {translation}
  \end{example}
  \begin{example}
    \digloss{Word}
            {gloss}
            {translation}
  \end{example}

\end{document}

image

Once again, thank you for your work on this package, and let me know if I can provide any more information on this issue. Best regards, Mark.

jspitz commented 1 year ago

The new and recommended way to do global changes is via \setglossoptions, and this works:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[TS1,T1]{fontenc}

\usepackage{covington}
\setglossoptions{fsi={\normalfont\itshape},
             fsii={\footnotesize\sffamily},
             fsiii={\footnotesize\sffamily}}

\usepackage{hyperref}

\begin{document}

    \trigloss[fsii={\itshape}]{building}
    {build -ing}
    {gloss GRAM}
    {translation}

    \begin{example}
        \digloss{Word}
        {gloss}
        {translation}
    \end{example}

\end{document}

image

Having written that, the old way of course should continue to work, and I think I know where the problem is.

jspitz commented 1 year ago

Should be fixed in the repository. Please test and report back if possible,

Marcool04 commented 1 year ago

Wonderful! The bug is verified to be gone, when using the \renewcommand{\glosslineone} etc. method. I'll switch to using the recommended \setglossoptions in the future. Congratulations and thank you for the very fast fix.

jspitz commented 1 year ago

I had to amend the fix, as it did not work with low-level command glossing.

Can I ask you to test again with the recent version in the repo? Thanks.

Marcool04 commented 1 year ago

Sure no problem. Tested and seems to work for me. I used this "low level" example from the documentation:

\NeedsTeXFormat{LaTeX2e}
\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[TS1,T1]{fontenc}

\usepackage{/home/mark/Downloads/test/covington}
\renewcommand{\glosslineone}{\normalfont\itshape}
\renewcommand{\glosslinetwo}{\footnotesize\sffamily}
\renewcommand{\glosslinethree}{\footnotesize\sffamily}

\usepackage{hyperref}

\begin{document}

  \trigloss[fsii={\itshape}]{building}
           {build -ing}
           {gloss GRAM}
           {translation}

  \gll Dit is een Nederlands voorbeeld.
  This is a Dutch example.
  \glt ‘This is an example in Dutch.’
  \glend

  \begin{example}
    \digloss{Word}
            {gloss}
            {translation}
  \end{example}

\end{document}
jspitz commented 1 year ago

Excellent, thank you so much!

Marcool04 commented 1 year ago

No problem, thank you for maintaining covington 😊

jspitz commented 1 year ago

V. 2.12 has been submitted to CTAN.

amunn commented 1 year ago

Hi Jürgen, I'm raising this here because this fix doesn't quite do what I would like it to do, and I'm hoping there's a simple fix. Consider the following MWE:

\documentclass{article}
\usepackage{covington}
\setglossoptions{fsi=\bfseries}
\begin{document}
\begin{subexamples}
\item \glosslineone Hello
\item \makeatletter\glosslineone@global Hello 
\end{subexamples}
\end{document}

I would expect setting the global gloss options would also change \glosslineone, but it doesn't. Conversely, if you comment out the \glossoptions line, the second item fails because \glosslineone@global isn't defined.

I'd like this specifically to work outside of the glossing environments provided by covington.

To add a bit more context, I've just released a package allowing use of ExPex glossing macros with other example packages (in addition to their own glossing macros). I'm happy to support covington too, so this would allow me to set the basic parameters of the ExPex gloss to be the same as the covington settings.

jspitz commented 1 year ago

@amunn it is like that to keep the direct definition of \glosslineone etc. intact and make examples like the one given in the first post here continue to work.

I don't know enough about your usecase, but would something like this work for you?

\newcommand*{\amglosslineone}{%
  \@ifundefined{glosslineone@global}{\glosslineone}{\glosslineone@global}%
}

This would support both \setglossoptions and the more basic direct redefinition of \glosslineone, whichever currently is valid.

amunn commented 1 year ago

I guess I don't really understand why \glosslineone@global isn't set unless you use \setglossoptions. My goal here is to make things easier for covington users, so I have no intention of creating a new command. Maybe I should ask the question differently: in the neutral case, which macro from covington stores the formatting for the first gloss line?

jspitz commented 1 year ago

I guess I don't really understand why \glosslineone@global isn't set unless you use \setglossoptions.

Because we check whether it has been defined in that command. Otherwise we use the (possibly manually defined) \glosslineone (which is the older approach and hence expected in some documents). Changing that would break backwards compatibility.

My goal here is to make things easier for covington users, so I have no intention of creating a new command.

Well it would be a one-liner that would arguably make things easier for covington users :-)

Maybe I should ask the question differently: in the neutral case, which macro from covington stores the formatting for the first gloss line?

There is not one "neutral" case. There is the (traditional) case of glossing with low-level commands and the (more recent and now recommended) case of using the \[di|tri]gloss macros.

Ultimately, it is always \glosslineone that is being used. But there are different ways to set that: (1.) via redefinition of \glosslineone, (2.) via \setglossoptions, and (3.) via gloss optional argument (only for the current gloss). (3.) overwrites (2.) overwrites (1.).

jspitz commented 1 year ago

Ultimately, it is always \glosslineone that is being used. But there are different ways to set that: (1.) via redefinition of \glosslineone, (2.) via \setglossoptions, and (3.) via gloss optional argument (only for the current gloss). (3.) overwrites (2.) overwrites (1.).

And the three ways have different scopes:

(3.) only applies to to current gloss (2.) applies to all glosses that use the \digloss and \trigloss macros (unless 3 is set) (1.) applies everywhere (unless 2 or 3 are set)

Hope this helps.

amunn commented 1 year ago

Ok thanks. I think I spoke to quickly on the macro you propose; it doesn't need to be user facing. I'll do that. I'm still not sure I understand the distinction between your (2) and (1). :) But no need to explain more.