0

I am currently writing my thesis in Greek, but I have to cite mostly English sources. My bibliography file looks like this:

@online{microsoft-memory-safety-errors,
    author={\en{MSRC Team}},
    title={\en{A proactive approach to more secure code}},
    url={\en{https://msrc-blog.microsoft.com/2019/07/16/a-proactive-approach-to-more-secure-code/}},
    year={2019},
    month={7}
}

Although \en{} works fine for the author and title fields, it fails to work with the URL field, creating the reference as follows:

MSRC Team. «A proactive approach to more secure code». (Ιούλ. 2019), διεύθν.:
%5ἓν%7Βηττπς://μσρς-βλογ.μιςροσοφτ.ςομ/2019/07/16/α-προαςτιvε-αππροαςη-
το-μορε-σεςυρε-ςοδε/%7Δ.

main.tex:

\documentclass[11pt,a4paper,english,greek,twoside]{book}

\usepackage[greek]{babel}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber,style=ieee]{biblatex}
\addbibresource{chapters/bibliography.bib}

% typeset short english phrases
\newcommand{\en}[1]{\foreignlanguage{english}{#1}}

\selectlanguage{greek}

\begin{document}
    Κείμενο \en{Text}\cite{microsoft-memory-safety-errors}
    
    \printbibliography
\end{document}
7
  • 5
    that can't work. Url is handled with rather special code. Show a complete example so that one can test solutions. Nov 29, 2021 at 19:04
  • 1
    In particular, please tell us whether you load the url or (better still) the xurl package.
    – Mico
    Nov 29, 2021 at 19:07
  • @Mico Yes I am loading url with the hyphens option. I tried to substitute it with hyperref but to no avail.
    – AQUATH
    Nov 29, 2021 at 19:09
  • 3
    Make a small but complete example. So remove unneeded packages but add the document body. Do not use \include. Nov 29, 2021 at 19:33
  • 2
    you have a problem with a bib entry. You only need a \cite command to demontrate it. All the other text is quite probably irrelevant. At best copy everything in a test folder and then start to remove things until you have a small example. Nov 29, 2021 at 20:18

1 Answer 1

1

For entries which are fully english, consider to use the langid field and the language option of biblatex to switch the language. This will also translate for example the date. The effect can be seen in the first entry.

If you prefer to switch to english only for special fields with your \en command: don't use it for an url, that will simply break.

url's should typically always be in a latin/ascii so the easiest is to switch the encoding in \UrlFont.

I used article as class to get everything on one page.

\documentclass[11pt,a4paper,english,greek,twoside]{article}
\usepackage[greek]{babel}

\usepackage[style=ieee,language=auto,autolang=other]{biblatex}
\addbibresource{test.bib}

% typeset short english phrases
\newcommand{\en}[1]{\foreignlanguage{english}{#1}}

\usepackage{xurl} %more break points 
\renewcommand\UrlFont{\fontencoding{T1}\ttfamily}


\begin{document}

    \url{https://msrc-blog.microsoft.com/2019/07/16/a-proactive-approach-to-more-secure-code/}
    
    Κείμενο \en{Text}
    
    \cite{microsoft-memory-safety-errors}
    \cite{microsoft-memory-safety-errors-var}

    \printbibliography
\end{document}

used bib entries

@online{microsoft-memory-safety-errors,
    author={MSRC Team},
    title={A proactive approach to more secure code},
    url={https://msrc-blog.microsoft.com/2019/07/16/a-proactive-approach-to-more-secure-code/},
    year={2019},
    month={7},
    langid={english}
}

@online{microsoft-memory-safety-errors-var,
    author={\en{MSRC Team}},
    title={\en{A proactive approach to more secure code}},
    url={https://msrc-blog.microsoft.com/2019/07/16/a-proactive-approach-to-more-secure-code/},
    year={2019},
    month={7},
}

enter image description here

2
  • Awesome! So, since I prefer the second variant, the renewed \UrlFont does the job without having to use the autolang option on biblatex. Am I missing something?
    – AQUATH
    Nov 30, 2021 at 18:01
  • Well good small examples make it quite easy to answer. And yes, if you prefer the second simply redefine \Urlfont. Nov 30, 2021 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.