0

I'm writing my bachelor's thesis in the Finnish language. We are provided with a template that can be used, and I'm going off it. It's my first time using LaTeX and basically all the complicated things the template does are magic to me.

The problem I'm having is that urldate comes out grammatically incorrect to the bibliography.
Take this example:

@online{test,
  author = {An Author},
  title = {This is the title},
  url = {https://www.url.com/},
  year = {2023},
  urldate = {2023-04-15}
}

I'm using the APA style that is provided by the template, so this comes out to the bibliography as:
Author, A. (2023). This is the title. Haettu huhtikuuta 15, 2023, osoitteesta https://www.url.com/
However, Haettu huhtikuuta 15, 2023 is grammatically incorrect and it should be Haettu 15. huhtikuuta, 2023. Or perhaps even more preferably Haettu 15.4.2023.

Is there something I can do to fix this grammatical error? To me it seems like these translations/formatting just come from some package that is specified in the tauthesis.cls file. Would it need to be fixed upstream somewhere?


EDIT:
As per @CarLaTeX's comment, currently the problem is fixed to the point, that the bibliography text is very close to being grammatically correct. Now only the comma (,) after the urldate needs to be get rid of here:
img

Here is a "minimal" (sorry, not so minimal, I don't know what all I can remove from the template without breaking it) example of what I'm working with:
https://www.overleaf.com/read/thvfdcfwgkxh

0x464e
  • 121
  • 6
  • 2
    well you could adapt that locally, but it would be better to report that at https://github.com/plk/biblatex-apa – Ulrike Fischer Apr 15 '23 at 21:04
  • How could I adapt it locally? Unfortunately right now I don't have time to report and wait for a fix upstream. Though it's a good idea to make an issue on that Github and I should do that later for sure. – 0x464e Apr 15 '23 at 21:17
  • see e.g. https://tex.stackexchange.com/a/546584/2388. But reporting is perhaps faster ... – Ulrike Fischer Apr 15 '23 at 21:20
  • That indeed does seem complicated and I really can't be asked to try to understand it. I still have a few weeks left before I need to turn in this thesis, so I guess I'll try my luck with reporting the issue on Github. – 0x464e Apr 15 '23 at 21:33
  • @CarLaTeX You're not using the APA style. I changed \ExecuteOptions{finnish,numeric} to \ExecuteOptions{finnish,apa} in tauthesis.cls – 0x464e Apr 15 '23 at 22:41
  • Yes, you're right. Will keep in mind. – 0x464e Apr 16 '23 at 09:44

1 Answers1

5

You modified tauthesis.cls changing \ExecuteOptions{finnish,numeric} to \ExecuteOptions{finnish,apa}.

You could also add urldate=short when BiBLaTeX is required:

\RequirePackage
    [backend=biber,
    autolang=other,
    urldate=short,
    citestyle=\@citationstyle,
    bibstyle=\@citationstyle]{biblatex}

After doing it, your citation will appear this way:

\begin{filecontents}[overwrite]{references.bib}
@online{test,
  author = {An Author},
  title = {This is the title},
  url = {https://www.url.com/},
  year = {2023},
  urldate = {2023-04-15}
}
\end{filecontents}

\pdfminorversion=6

\documentclass{tauthesis} \usepackage{amsmath, amssymb, amsthm} \newcommand{\verbcommand}[1]{\texttt{\textbackslash #1}} \makeglossaries

\addbibresource{references.bib}

\begin{document}

Test citation \cite{test}.

\printbibliography[heading=bibintoc]

\end{document}

enter image description here

EDIT:
Redefining urldate:

\begin{filecontents*}[overwrite]{references.bib}
@online{test,
  author = {An Author},
  title = {This is the title of some cool site},
  url = {https://www.url.com/},
  year = {2023},
  urldate = {2023-04-15}
}

@online{test2, author = {An Authorr}, title = {Why doesn't this also wrap incorrectly}, subtitle = {so weird, I cant replicate}, url = {https://www.url.com/this-a-long-url-yeah-yeah-yeah-yeah.html}, year = {2023}, urldate = {2023-04-15} }

@online{SOAPvsREST, author = {Alyssa Walker}, title = {SOAP vs REST API}, subtitle = {Difference Between Web Services}, url = {https://www.guru99.com/comparison-between-web-services.html}, year = {2023}, urldate = {2023-04-10} } \end{filecontents*}

\begin{filecontents}[overwrite]{\jobname.xmpdata} \Title{test} \Author{test} \Language{fi} \end{filecontents}

\pdfminorversion=6

\documentclass{tauthesis}

\usepackage{amsmath, amssymb, amsthm} \usepackage{hyperref} \hypersetup{hidelinks} % float placement \usepackage{float}

% svg support \usepackage{svg}

% landscape support \usepackage{lscape}

% long table support \usepackage{longtable}

% checkmark and x mark support from pifont's dingbats \usepackage{pifont} \newcommand{\cmark}{\ding{51}}% \newcommand{\xmark}{\ding{55}}%

%%%%% Your commands.

% added: \usepackage{microtype}

% Print verbatim LaTeX commands \newcommand{\verbcommand}[1]{\texttt{\textbackslash #1}}

\makeglossaries

% added: \DefineBibliographyStrings{finnish}{% urlseen = {Haettu\addspace},% urlfrom = {osoitteesta\addspace},% }

% added (thanks to moewe): \DeclareFieldFormat{urldate}{\bibstring{urlseen}~#1\space\bibstring{urlfrom}}

\renewbibmacro*{url+urldate}{% \usebibmacro{urldate}% \setunit{\addspace}% \usebibmacro{url}% }

\DefineBibliographyExtras{finnish}{% % d-m-y format for short dates \protected\def\mkbibdateshort#1#2#3{% \iffieldundef{#3} {} {\thefield{#3}% \iffieldundef{#2}{}{.}}% \iffieldundef{#2} {} {\thefield{#2}% \iffieldundef{#1}{}{.}}% \iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\mkyearzeros{\thefield{#1}}}}% } % added: \renewcommand*{\finentrypunct}{}

\addbibresource{references.bib}

\begin{document}

\chapter{test}

\cite{test} \cite{test2} \cite{SOAPvsREST}

\printbibliography[heading=bibintoc]

\end{document}

enter image description here

For the text that goes out of margins, you can load microtype package.

To remove the dot at the end you can use:

\renewcommand*{\finentrypunct}{}

but it will remove the final dot for all the entries.

CarLaTeX
  • 62,716
  • Awesome, thanks. Also, is there any chance you'd know why there appears to be a space after the dots? I hate to nitpick, but it looks really weird :/ Also there shouldn't be a comma after the date. That's grammatically incorrect. But I assume this is an issue with the biblatex-apa package itself and should be fixed upstream(?) – 0x464e Apr 16 '23 at 09:50
  • urldate=short will change only dates of urls, so one need to check if the wrong date format appears in other types (I don't know apa style good enough). – Ulrike Fischer Apr 16 '23 at 09:56
  • Thanks for showing \DeclareFieldFormat{urldate}. it fixed the spacing and now numbers aren't also incorrectly prefixed with a zero. That's was also grammatically incorrect, I didn't even notice at first. However the solution you proposed is not correct APA format (according to all Finnish APA citation guides I can find). But with with your tips and solution I'm so close now. Now I have Haettu 15.4.2023, osoitteesta and just need to get rid of the comma (,) after the date. – 0x464e Apr 17 '23 at 10:12
  • @CarLaTeX I updated the original answer with and edit and a Overleaf link of what I'm working with. Sorry I didn't make a new question, because I feel like it would pretty clearly just be a duplicate of this one. – 0x464e Apr 17 '23 at 20:44
  • @CarLaTeX Huh, that's odd. I did that and even made sure I was able to access the link in incognito. But it probably needs to be that /read link when it's accessed for the first time or something. Try now. – 0x464e Apr 18 '23 at 00:04
  • @0x464e See the code with % added: in the EDIT. I don't guarantee it won't cause problems elsewhere. – CarLaTeX Apr 18 '23 at 12:46
  • @CarLaTeX So close to perfect, now somehow a period (.) appears after the url, when it shouldn't. Also I found some weird wrapping issue with one of my sources. It overfills the space it should use. See the edited Overleaf if you're still willing to look at this. But thanks anyway, it's already much better than what I started with. – 0x464e Apr 18 '23 at 15:04
  • Unfortunately, I don't have the time to write an answer myself at the moment, but I'd just like to comment that \DeclareFieldFormat{urldate} with hardcoded \thefield{year} etc. is really bad style. The date format should be changed by redefining the relevant macros in the .lbx file (which are, admittedly and unfortunately, not particularly user friendly). See https://tex.stackexchange.com/a/201779/35864, https://tex.stackexchange.com/a/167046/35864, https://tex.stackexchange.com/a/141412/35864 for examples of how that could work. – moewe Apr 18 '23 at 16:53
  • @0x464e See my edit, again. For the text that goes out of margins, you can load microtype package. To remove the dot at the end you can use: \renewcommand*{\finentrypunct}{} but it will remove the final dot for all the entries. – CarLaTeX Apr 19 '23 at 08:52
  • @CarLaTeX Thanks for microtype. It did indeed fix the wrapping and a Google search tells me that it's overall a good package to have. And I think removing all dots would be even more wrong, so I'll cope with dots after links even though it's wrong. Side note: adding the microtype package gives me the following warning Unable to apply patch footnote on input line 218. ( the error is also visible in my linked Overleaf) A Google search tells me that it's something I should only worry about if I use footnotes (which I don't), so the warning is probably ok to ignore. – 0x464e Apr 19 '23 at 16:20
  • 1
    @0x464e You can ignore it. I think you can also suppress the warning by using the package microtype option nopatch=footnote. – CarLaTeX Apr 19 '23 at 19:34
  • Yeah. That looks much better. It would be slightly more idiomatic to have things like \bibstring{urlseen} and \bibstring{urlfrom} in a \DeclareFieldFormat instead of the bibmacro, but this is more probably more a matter of taste. – moewe Apr 26 '23 at 12:47
  • I can't compile the code, since I don't have the custom thesis class, but \DeclareFieldFormat{url+urldate} shouldn't work. \DeclareFieldFormat{<field format>} only does something useful if the field format exists. url+urldate is a bibmacro, but it is not a field format in all styles that I know of. I was thinking of something like https://gist.github.com/moewew/7b7b6a2a89f1ab63bfef412ba5759752 (both completely untested, plus it's late where I am, so probably there are some typos in there). But as I said: Your previous solution with \renewbibmacro was perfectly fine on a TeXnical level. – moewe Apr 26 '23 at 20:26
  • It works in the sense that it compiles. But the \DeclareFieldFormat{url+urldate} has no effect: Add something like ??? and it won't appear in the output. – moewe Apr 27 '23 at 06:38
  • Anyway, here are the two options I suggested yesterday in a working document https://gist.github.com/moewew/c036aa116aa5ee216bcc812f667318a5. – moewe Apr 27 '23 at 06:42
  • Does it though? I copied the project and added ??? to the \DeclareFieldFormat{url+urldate} line: It does not appear in the output. Note also that the undesired comma before "osoitteesta" is present again even though your code previously removed it. See https://www.overleaf.com/read/nqpmzxtkfqvq for my tests. – moewe Apr 27 '23 at 06:49
  • @moewe You're right, I didn't notice the comma \DeclareFieldFormat{url+urldate} is ignored – CarLaTeX Apr 27 '23 at 07:21
  • @moewe I chose Option 1 because Option 2 breaks the URL hyphenation – CarLaTeX Apr 27 '23 at 08:04
  • Oh yeah, I forgot about the original field format for url. I fixed the second option in the link. Note that the output of the two solutions is different if no urldate is given. – moewe Apr 27 '23 at 10:35
  • @moewe I see, thank you for all! – CarLaTeX Apr 27 '23 at 12:46