Re: biblatex usepackage location in the preamble

2019-01-30 Thread Jürgen Spitzmüller
>
> https://github.com/plk/biblatex/issues/867
>
> I will keep list posted.
>

Excellent.
Jürgen

BE
>
> --
>
> ↓↓
> Please bottom-post. Start your reply here:
>
>


Re: biblatex usepackage location in the preamble

2019-01-30 Thread Baris Erkus
On 29-Jan-19 1:18 PM, Jürgen Spitzmüller wrote:
Great. You could also file a ticket at the biblatex tracker to make people 
aware of your effort. This might help attracting other:
https://github.com/plk/biblatex/issues

Jürgen


https://github.com/plk/biblatex/issues/867

I will keep list posted.

BE

--

↓↓
Please bottom-post. Start your reply here:


Re: biblatex usepackage location in the preamble

2019-01-29 Thread Jürgen Spitzmüller
Am Di., 29. Jan. 2019 um 10:53 Uhr schrieb Baris Erkus <
bariser...@hotmail.com>:

> No, it is part of the preamble:
> http://joshua.smcvt.edu/latex2e/_005cAtBeginDocument.html
>
> I couldn't confirm this. See for example this SE answer
> .
> Anyhow, this may be an issue related to the macro as you have said.
>
>
\AtBeginDocument is a somewhat liminal beast. Technically, it is part of
the preamble, but it is also issued at a stage where some things have
already been processed.

A good explanation is given by Philipp Lehman in the etoolbox manual:

"Any \AtBeginDocument code is executed towards the beginning of the
document body, after the main aux file has been read
for the first time. [...] In a way, \AtBeginDocument code is part neither
of the preamble nor the document body but located in-between them since it
gets executed in the middle of the
initialization sequence performed prior to typesetting. It is sometimes
desirable to move code to the end of the preamble because all requested
packages have been
loaded at this point. \AtBeginDocument code, however, is executed too late
if it is required in the aux file. In contrast to that, \AtEndPreamble code
is part of the
preamble."

This might be just the issue here.

> Adding a new localization is quite straightforward and not too much work.
> If you feel like contributing that, it would be a good way to "give back"
> to the community:
>
> https://github.com/plk/biblatex/wiki/Checklist-for-submitting-a-new-localisation-file-(.lbx)
>
> Actually, I have spent couple of hours working on a Turkish lbx file
> yesterday. Indeed, it does not look complicated. Still it requires
> attention from people with expertise in Turkish publishing rules.
>
> I will start a GitHub project on this, and see if I can get help ldx. I
> will fix the parts that I need in the mean time.
>
Great. You could also file a ticket at the biblatex tracker to make people
aware of your effort. This might help attracting other:
https://github.com/plk/biblatex/issues

Jürgen



> Thanks for the help!
> --
>
> ↓↓
> Please bottom-post. Start your reply here:
>
>


Re: biblatex usepackage location in the preamble

2019-01-29 Thread Baris Erkus
On 29-Jan-19 12:15 PM, Jürgen Spitzmüller wrote:
Am Mo., 28. Jan. 2019 um 19:51 Uhr schrieb Baris Erkus 
mailto:bariser...@hotmail.com>>:
Thanks Jürgen. This one I understand. However, this requirement does not call 
for loading babel+biblatex right before the \begin{document}; they can still be 
placed right after other packages loaded after \documentclass. The examples on 
BibLaTeX, I sqw SE or other web pages loads BibLaTeX in the block after 
\documentclass, but late.

The loading order of packages is tricky. Some packages need to be loaded after 
the user preamble, and babel needs to be loaded after that, and biblatex after 
babel. Just because this works in your case in the different order does not 
mean it works generally.
Exactly. However, I am not sure if they have to be placed right before the 
\begin{document}.

The only way around that would be a second user preamble:
https://www.lyx.org/trac/ticket/5366
+1

It does compiling, but the replacement did not work.

I think, the \AtBeginDocument{...}  macro places the contents right after the 
\begin{document}, but not in the preamble.

No, it is part of the preamble:
http://joshua.smcvt.edu/latex2e/_005cAtBeginDocument.html

I couldn't confirm this. See for example this SE 
answer.
 Anyhow, this may be an issue related to the macro as you have said.

[cid:part5.9F8AAA3C.23830C58@hotmail.com]


Try instead:

\usepackage{etoolbox}
\AtEndPreamble{%
...
}
This worked! This is what I need.
Adding a new localization is quite straightforward and not too much work. If 
you feel like contributing that, it would be a good way to "give back" to the 
community:
https://github.com/plk/biblatex/wiki/Checklist-for-submitting-a-new-localisation-file-(.lbx)

Actually, I have spent couple of hours working on a Turkish lbx file yesterday. 
Indeed, it does not look complicated. Still it requires attention from people 
with expertise in Turkish publishing rules.

I will start a GitHub project on this, and see if I can get help ldx. I will 
fix the parts that I need in the mean time.

Thanks for the help!

--

↓↓
Please bottom-post. Start your reply here:


Re: biblatex usepackage location in the preamble

2019-01-29 Thread Jürgen Spitzmüller
Am Mo., 28. Jan. 2019 um 19:51 Uhr schrieb Baris Erkus <
bariser...@hotmail.com>:

> Thanks Jürgen. This one I understand. However, this requirement does not
> call for loading babel+biblatex right before the \begin{document}; they can
> still be placed right after other packages loaded after \documentclass. The
> examples on BibLaTeX, I sqw SE or other web pages loads BibLaTeX in the
> block after \documentclass, but late.
>

The loading order of packages is tricky. Some packages need to be loaded
after the user preamble, and babel needs to be loaded after that, and
biblatex after babel. Just because this works in your case in the different
order does not mean it works generally.

The only way around that would be a second user preamble:
https://www.lyx.org/trac/ticket/5366


> It does compiling, but the replacement did not work.
>
> I think, the \AtBeginDocument{...}  macro places the contents right after
> the \begin{document}, but not in the preamble.
>
No, it is part of the preamble:
http://joshua.smcvt.edu/latex2e/_005cAtBeginDocument.html

> However, the \DefineBibliographyStrings{...} and similar BibLaTeX commands
> are placed in the preamble according to Section 3.9 of BibLaTeX manual.
> Maybe this is the reason it does not do the replacement (?).
>
I don't think so. The reason might be that it comes too late for biblatex,
which hooks itself into the document.

Try instead:

\usepackage{etoolbox}
\AtEndPreamble{%
...
}


>
> (TBH, this was not my original problem. I was trying to use BibLaTeX for a
> Turkish document, only to find out BibLaTeX does not have Turkish support
> yet :< )
>
Adding a new localization is quite straightforward and not too much work.
If you feel like contributing that, it would be a good way to "give back"
to the community:
https://github.com/plk/biblatex/wiki/Checklist-for-submitting-a-new-localisation-file-(.lbx)

HTH
Jürgen


> Baris
>
> --
> ↓↓
> Please bottom-post. Start your reply here:
>
>


Re: biblatex usepackage location in the preamble

2019-01-29 Thread Baris Erkus
On 29-Jan-19 9:14 AM, Daniel wrote:
> If I read the documentations for \AtBeginDocument correctly, it places 
> the macro just before \begin{document}. Is your .tex test file working 
> as expected when you move your macro manually to whatever position you 
> think it should be moved? If not then the problem might be the macro 
> rather than LyX.
>
> Daniel
>
The macro works fine if I place it to the required location manually (I 
have sent the LaTeX file in the first e-mail for the record).
The loading sequence of the packages should be like the following 
according the BibLaTeX, which works as expected:

\documentclass[english]{article}
**Misc Packages**
\usepackage{babel}
\usepackage[style=authoryear, maxcitenames=2]{biblatex}
\addbibresource{test.bib}

 Macro 
\DefineBibliographyStrings{english}{%
   references = {{Kaynaklar}},
   and = {ve},
   andothers ={ve diğerleri},
}
 End Macro 

\begin{document}
**Misc**
\printbibliography
\end{document}

Unfortunately, LyX does not do this format as you have mentioned and 
wrapping with macro to place at the beginning of the document does not work.

Baris



Re: biblatex usepackage location in the preamble

2019-01-28 Thread Daniel

On 2019-01-28 19:50, Baris Erkus wrote:

  It does compiling, but the replacement did not work.

I think, the \AtBeginDocument{...}  macro places the contents right 
after the \begin{document}, but not in the preamble. However, the 
\DefineBibliographyStrings{...} and similar BibLaTeX commands are placed 
in the preamble according to Section 3.9 of BibLaTeX manual. Maybe this 
is the reason it does not do the replacement (?).


I have also tried to compile a LaTeX file where I place this block to 
the beginning of the document right after \begin{document} and it gives 
error that this has to be placed in the preamble (no LyX involved).


I further tested the case on LaTeX again, where the above block wrapped 
with \AtBeginDocument{...} in the preamble, but before loading biblatex; 
it compiles, but it does not do the replacement (no LyX involved).


So, is there a workaround for this in LyX, am I missing smtg?

(TBH, this was not my original problem. I was trying to use BibLaTeX for 
a Turkish document, only to find out BibLaTeX does not have Turkish 
support yet :< )


If I read the documentations for \AtBeginDocument correctly, it places 
the macro just before \begin{document}. Is your .tex test file working 
as expected when you move your macro manually to whatever position you 
think it should be moved? If not then the problem might be the macro 
rather than LyX.


Daniel



Re: biblatex usepackage location in the preamble

2019-01-28 Thread Baris Erkus
On 28-Jan-19 7:46 PM, Jürgen Spitzmüller wrote:
Am Mo., 28. Jan. 2019 um 16:40 Uhr schrieb Baris Erkus 
mailto:bariser...@hotmail.com>>:

I observed that if biblatex is selected for the bibliography style, the 
\usepackage[*options*]{biblatex} is placed right before the \begin{document}, 
but not after the \documentclass, where usually packages are called.

Yes, because biblatex must be loaded after babel (or polyglossia), and this, in 
turn, must be loaded late.
Thanks Jürgen. This one I understand. However, this requirement does not call 
for loading babel+biblatex right before the \begin{document}; they can still be 
placed right after other packages loaded after \documentclass. The examples on 
BibLaTeX, I sqw SE or other web pages loads BibLaTeX in the block after 
\documentclass, but late.

If I want to place some code in the preamble that requires the biblatex 
package, then these codes appear before the \usepackage[*options*]{biblatex} 
line, and they do not work.

For example I wanted to replace "et al.", "and", "Bibliography (title)" with 
their Turkish counterparts by simply placing the following code to the preamble:

\DefineBibliographyStrings{english}{%
  references = {{Kaynaklar}},
  and = {ve},
  andothers ={ve diğerleri},
}

but it does not work.

You need to embrace such definitions in \AtBeginDocument{...}. See
https://wiki.lyx.org/BibTeX/Biblatex#toc2

HTH,
Jürgen


 It does compiling, but the replacement did not work.

I think, the \AtBeginDocument{...}  macro places the contents right after the 
\begin{document}, but not in the preamble. However, the 
\DefineBibliographyStrings{...} and similar BibLaTeX commands are placed in the 
preamble according to Section 3.9 of BibLaTeX manual. Maybe this is the reason 
it does not do the replacement (?).

I have also tried to compile a LaTeX file where I place this block to the 
beginning of the document right after \begin{document} and it gives error that 
this has to be placed in the preamble (no LyX involved).

I further tested the case on LaTeX again, where the above block wrapped with 
\AtBeginDocument{...} in the preamble, but before loading biblatex; it 
compiles, but it does not do the replacement (no LyX involved).

So, is there a workaround for this in LyX, am I missing smtg?

(TBH, this was not my original problem. I was trying to use BibLaTeX for a 
Turkish document, only to find out BibLaTeX does not have Turkish support yet 
:< )

Baris

--
↓↓
Please bottom-post. Start your reply here:
%% LyX 2.3.2-2 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}


\AtBeginDocument{%
\DefineBibliographyStrings{english}{%
  references = {{Kaynaklar}},
  and = {ve},
  andothers ={ve diğerleri},
}
}


\usepackage{babel}
\usepackage[style=authoryear,maxcitenames=2]{biblatex}

\addbibresource{test.bib}

\begin{document}

Testing \parencite{Nagarajaiah1991} Testing \parencite{AtikAbrahamson2010}

\printbibliography

\end{document}


newfile1-biblatex-2.lyx
Description: newfile1-biblatex-2.lyx


Re: biblatex usepackage location in the preamble

2019-01-28 Thread Jürgen Spitzmüller
Am Mo., 28. Jan. 2019 um 16:40 Uhr schrieb Baris Erkus <
bariser...@hotmail.com>:

> I observed that if biblatex is selected for the bibliography style, the
> \usepackage[*options*]{biblatex} is placed right before the
> \begin{document}, but not after the \documentclass, where usually packages
> are called.
>
Yes, because biblatex must be loaded after babel (or polyglossia), and
this, in turn, must be loaded late.

> If I want to place some code in the preamble that requires the biblatex
> package, then these codes appear before the
> \usepackage[*options*]{biblatex} line, and they do not work.
>
> For example I wanted to replace "et al.", "and", "Bibliography (title)"
> with their Turkish counterparts by simply placing the following code to the
> preamble:
>
> \DefineBibliographyStrings{english}{%
>   references = {{Kaynaklar}},
>   and = {ve},
>   andothers ={ve diğerleri},
> }
>
> but it does not work.
>
You need to embrace such definitions in \AtBeginDocument{...}. See
https://wiki.lyx.org/BibTeX/Biblatex#toc2

HTH,
Jürgen