Re: Creating bookmarks based on passage in the text

2016-05-01 Thread racoon

On 01.05.2016 01:01, Richard Heck wrote:

On 04/30/2016 02:13 PM, racoon wrote:

On 30.04.2016 19:51, racoon wrote:

On 30.04.2016 18:10, Richard Heck wrote:

On 04/30/2016 11:55 AM, racoon wrote:

On 30.04.2016 16:56, Richard Heck wrote:

On 04/30/2016 10:00 AM, racoon wrote:

Thanks Jürgen. I guess your reply implies that there is no special
function for this in LyX.


No, but it would not be hard to create a simple module that did this.


I'll give it a try. Two things are holding me a bit back though

1. The code by Jürgen does not work in environments.


May need to use \csgdef or something. It's possible the defintion is
being made local to the environment. But I'm not sure.


Well, if it is without LyX help then there are the necessary commands
already in the hyperref package: \hypertarget and \hyperref.

https://en.wikibooks.org/wiki/LaTeX/Hyperlinks#Hyperlink_and_Hypertarget

They uglify the text though.


Just for completeness, here is a solution:

http://tex.stackexchange.com/questions/168832/using-hypertarget-caption-in-hyperlink-caption


However, without the help of a frontend that provides a list of
labels, like LyX does for other cross references, it is pretty
cumbersome and makes the text less readable in the editor.

Is it possible to implement such a list via a module or would one have
to dig deeper into LyX for that?


Having a dialog that does the sort of thing you want---a lot like the
cross-reference dialog, it seems to me---would require actual coding.
You are welcome to file an enhancement request, but those sorts of
things tend to get done by someone who has an itch to scratch


I see. Too bad it seems modules can't handle that case. I have filed an 
enhancement request


http://www.lyx.org/trac/ticket/10116

And it actually seems that someone has requested something similar before

http://www.lyx.org/trac/ticket/8282

I am not sure whether that is a good or bad thing. Maybe someone will 
start to feel the itch by being pointed to it


Daniel



Richard







Re: Creating bookmarks based on passage in the text

2016-04-30 Thread Richard Heck
On 04/30/2016 02:13 PM, racoon wrote:
> On 30.04.2016 19:51, racoon wrote:
>> On 30.04.2016 18:10, Richard Heck wrote:
>>> On 04/30/2016 11:55 AM, racoon wrote:
 On 30.04.2016 16:56, Richard Heck wrote:
> On 04/30/2016 10:00 AM, racoon wrote:
>> Thanks Jürgen. I guess your reply implies that there is no special
>> function for this in LyX.
>
> No, but it would not be hard to create a simple module that did this.

 I'll give it a try. Two things are holding me a bit back though

 1. The code by Jürgen does not work in environments.
>>>
>>> May need to use \csgdef or something. It's possible the defintion is
>>> being made local to the environment. But I'm not sure.
>>
>> Well, if it is without LyX help then there are the necessary commands
>> already in the hyperref package: \hypertarget and \hyperref.
>>
>> https://en.wikibooks.org/wiki/LaTeX/Hyperlinks#Hyperlink_and_Hypertarget
>>
>> They uglify the text though.
>
> Just for completeness, here is a solution:
>
> http://tex.stackexchange.com/questions/168832/using-hypertarget-caption-in-hyperlink-caption
>
>
> However, without the help of a frontend that provides a list of
> labels, like LyX does for other cross references, it is pretty
> cumbersome and makes the text less readable in the editor.
>
> Is it possible to implement such a list via a module or would one have
> to dig deeper into LyX for that?

Having a dialog that does the sort of thing you want---a lot like the
cross-reference dialog, it seems to me---would require actual coding.
You are welcome to file an enhancement request, but those sorts of
things tend to get done by someone who has an itch to scratch

Richard



Re: Creating bookmarks based on passage in the text

2016-04-30 Thread racoon

On 30.04.2016 20:13, racoon wrote:

On 30.04.2016 19:51, racoon wrote:

On 30.04.2016 18:10, Richard Heck wrote:

On 04/30/2016 11:55 AM, racoon wrote:

On 30.04.2016 16:56, Richard Heck wrote:

On 04/30/2016 10:00 AM, racoon wrote:

Thanks Jürgen. I guess your reply implies that there is no special
function for this in LyX.


No, but it would not be hard to create a simple module that did this.


I'll give it a try. Two things are holding me a bit back though

1. The code by Jürgen does not work in environments.


May need to use \csgdef or something. It's possible the defintion is
being made local to the environment. But I'm not sure.


Well, if it is without LyX help then there are the necessary commands
already in the hyperref package: \hypertarget and \hyperref.

https://en.wikibooks.org/wiki/LaTeX/Hyperlinks#Hyperlink_and_Hypertarget

They uglify the text though.


Just for completeness, here is a solution:

http://tex.stackexchange.com/questions/168832/using-hypertarget-caption-in-hyperlink-caption


However, without the help of a frontend that provides a list of labels,
like LyX does for other cross references, it is pretty cumbersome and
makes the text less readable in the editor.

Is it possible to implement such a list via a module or would one have
to dig deeper into LyX for that?


I just realized that LyX has a "problem" with this solution. If the 
caption of the link is changed and the preview is created the hyperlink 
is not appropriately updated. It seems that it needs an extra compilation...


Daniel



Daniel



Daniel




2. The Customization documentation seems a bit on the short side when
it comes to examples.


All the layout and module files that LyX ships are examples, e.g.,
enumitem.module.

Richard














hypertarget.lyx
Description: application/lyx


Re: Creating bookmarks based on passage in the text

2016-04-30 Thread racoon

On 30.04.2016 19:51, racoon wrote:

On 30.04.2016 18:10, Richard Heck wrote:

On 04/30/2016 11:55 AM, racoon wrote:

On 30.04.2016 16:56, Richard Heck wrote:

On 04/30/2016 10:00 AM, racoon wrote:

Thanks Jürgen. I guess your reply implies that there is no special
function for this in LyX.


No, but it would not be hard to create a simple module that did this.


I'll give it a try. Two things are holding me a bit back though

1. The code by Jürgen does not work in environments.


May need to use \csgdef or something. It's possible the defintion is
being made local to the environment. But I'm not sure.


Well, if it is without LyX help then there are the necessary commands
already in the hyperref package: \hypertarget and \hyperref.

https://en.wikibooks.org/wiki/LaTeX/Hyperlinks#Hyperlink_and_Hypertarget

They uglify the text though.


Just for completeness, here is a solution:

http://tex.stackexchange.com/questions/168832/using-hypertarget-caption-in-hyperlink-caption

However, without the help of a frontend that provides a list of labels, 
like LyX does for other cross references, it is pretty cumbersome and 
makes the text less readable in the editor.


Is it possible to implement such a list via a module or would one have 
to dig deeper into LyX for that?


Daniel



Daniel




2. The Customization documentation seems a bit on the short side when
it comes to examples.


All the layout and module files that LyX ships are examples, e.g.,
enumitem.module.

Richard











Re: Creating bookmarks based on passage in the text

2016-04-30 Thread racoon

On 30.04.2016 18:10, Richard Heck wrote:

On 04/30/2016 11:55 AM, racoon wrote:

On 30.04.2016 16:56, Richard Heck wrote:

On 04/30/2016 10:00 AM, racoon wrote:

Thanks Jürgen. I guess your reply implies that there is no special
function for this in LyX.


No, but it would not be hard to create a simple module that did this.


I'll give it a try. Two things are holding me a bit back though

1. The code by Jürgen does not work in environments.


May need to use \csgdef or something. It's possible the defintion is
being made local to the environment. But I'm not sure.


Well, if it is without LyX help then there are the necessary commands 
already in the hyperref package: \hypertarget and \hyperref.


https://en.wikibooks.org/wiki/LaTeX/Hyperlinks#Hyperlink_and_Hypertarget

They uglify the text though.

Daniel




2. The Customization documentation seems a bit on the short side when
it comes to examples.


All the layout and module files that LyX ships are examples, e.g.,
enumitem.module.

Richard







Re: Creating bookmarks based on passage in the text

2016-04-30 Thread racoon

On 30.04.2016 17:55, racoon wrote:

On 30.04.2016 16:56, Richard Heck wrote:

On 04/30/2016 10:00 AM, racoon wrote:

Thanks Jürgen. I guess your reply implies that there is no special
function for this in LyX.


No, but it would not be hard to create a simple module that did this.


I'll give it a try. Two things are holding me a bit back though

1. The code by Jürgen does not work in environments.
2. The Customization documentation seems a bit on the short side when it
comes to examples.


Also, it would be nicer to have a bookmark front end like the one for 
other references. So, for example, when you change the *label* of the 
bookmark it automatically everywhere elsewhere in the document. 
Actually, I guess the distinction between *label* and *content* is 
somewhat unhappy. Would be good if the content just is the label, or the 
content is all that is visible to the user in the editor. In this way 
the text remains very readable. Internally, LyX could just give any 
bookmark a number or so. But where the bookmark is defined and where its 
reference is inserted there just the content is visible. Maybe with some 
frame to make clear that it is a bookmark... wishful thinking.


Daniel



Daniel



Richard




A problem with the solution you posted is that it seems to work only
in the case when the bookmark is set in a normal paragraph. Otherwise
it seems to fail for some reason. I have attached an example.

On 30.04.2016 14:53, Jürgen Spitzmüller wrote:

Am Samstag, den 30.04.2016, 09:36 +0200 schrieb racoon:

Hi,

In word you can create bookmarks based on a passage in the text. Is
there such a feature in LyX?

So basically it would work like this:

1. You mark a passage (e.g. a word).
2. You make it a bookmark.
2. You go somewhere else and insert a cross reference top the
bookmark.
This will lead to the content of the bookmark being inserted and a
hyperlink to that passage being created.

I think it is a nice idea to create hyperlinks (like in Wikipedia)
to
certain terms that are explained elsewhere. Also if one changes
one's
mind about the term one can just change it at the bookmark and it is
changed everywhere in the text.

(I guess it is similar to creating a definition in LaTeX

\def\foo{Whatever}

So one can use now \foo to insert "Whatever" in the text and can
change
what is actually inserted in the definition. What is missing is the
hyperlink part to the bookmark. So it is not exactly the same.)



Preamble:

\usepackage{etoolbox}
\usepackage{hyperref}
\newcommand\setbookmark[2]{%
\csdef{bkmk@#1}{#2}%
\label{bkmk:#1}%
#2
}

\newcommand\usebookmark[1]{%
\hyperref[bkmk:#1]{\csuse{bkmk@#1}}%
}


Usage:

\setbookmark{test}{A test!}
marks the bookmark "test" and prints the text "a test!"


\usebookmark{test}
prints the text "a test!" as a hyperlink to the former occurrence.

HTH
Jürgen




Best,
Daniel
















Re: Creating bookmarks based on passage in the text

2016-04-30 Thread Richard Heck
On 04/30/2016 11:55 AM, racoon wrote:
> On 30.04.2016 16:56, Richard Heck wrote:
>> On 04/30/2016 10:00 AM, racoon wrote:
>>> Thanks Jürgen. I guess your reply implies that there is no special
>>> function for this in LyX.
>>
>> No, but it would not be hard to create a simple module that did this.
>
> I'll give it a try. Two things are holding me a bit back though
>
> 1. The code by Jürgen does not work in environments.

May need to use \csgdef or something. It's possible the defintion is
being made local to the environment. But I'm not sure.

> 2. The Customization documentation seems a bit on the short side when
> it comes to examples.

All the layout and module files that LyX ships are examples, e.g.,
enumitem.module.

Richard



Re: Creating bookmarks based on passage in the text

2016-04-30 Thread racoon

On 30.04.2016 16:56, Richard Heck wrote:

On 04/30/2016 10:00 AM, racoon wrote:

Thanks Jürgen. I guess your reply implies that there is no special
function for this in LyX.


No, but it would not be hard to create a simple module that did this.


I'll give it a try. Two things are holding me a bit back though

1. The code by Jürgen does not work in environments.
2. The Customization documentation seems a bit on the short side when it 
comes to examples.


Daniel



Richard




A problem with the solution you posted is that it seems to work only
in the case when the bookmark is set in a normal paragraph. Otherwise
it seems to fail for some reason. I have attached an example.

On 30.04.2016 14:53, Jürgen Spitzmüller wrote:

Am Samstag, den 30.04.2016, 09:36 +0200 schrieb racoon:

Hi,

In word you can create bookmarks based on a passage in the text. Is
there such a feature in LyX?

So basically it would work like this:

1. You mark a passage (e.g. a word).
2. You make it a bookmark.
2. You go somewhere else and insert a cross reference top the
bookmark.
This will lead to the content of the bookmark being inserted and a
hyperlink to that passage being created.

I think it is a nice idea to create hyperlinks (like in Wikipedia)
to
certain terms that are explained elsewhere. Also if one changes
one's
mind about the term one can just change it at the bookmark and it is
changed everywhere in the text.

(I guess it is similar to creating a definition in LaTeX

\def\foo{Whatever}

So one can use now \foo to insert "Whatever" in the text and can
change
what is actually inserted in the definition. What is missing is the
hyperlink part to the bookmark. So it is not exactly the same.)



Preamble:

\usepackage{etoolbox}
\usepackage{hyperref}
\newcommand\setbookmark[2]{%
\csdef{bkmk@#1}{#2}%
\label{bkmk:#1}%
#2
}

\newcommand\usebookmark[1]{%
\hyperref[bkmk:#1]{\csuse{bkmk@#1}}%
}


Usage:

\setbookmark{test}{A test!}
marks the bookmark "test" and prints the text "a test!"


\usebookmark{test}
prints the text "a test!" as a hyperlink to the former occurrence.

HTH
Jürgen




Best,
Daniel













Re: Creating bookmarks based on passage in the text

2016-04-30 Thread Richard Heck
On 04/30/2016 10:00 AM, racoon wrote:
> Thanks Jürgen. I guess your reply implies that there is no special
> function for this in LyX.

No, but it would not be hard to create a simple module that did this.

Richard


>
> A problem with the solution you posted is that it seems to work only
> in the case when the bookmark is set in a normal paragraph. Otherwise
> it seems to fail for some reason. I have attached an example.
>
> On 30.04.2016 14:53, Jürgen Spitzmüller wrote:
>> Am Samstag, den 30.04.2016, 09:36 +0200 schrieb racoon:
>>> Hi,
>>>
>>> In word you can create bookmarks based on a passage in the text. Is
>>> there such a feature in LyX?
>>>
>>> So basically it would work like this:
>>>
>>> 1. You mark a passage (e.g. a word).
>>> 2. You make it a bookmark.
>>> 2. You go somewhere else and insert a cross reference top the
>>> bookmark.
>>> This will lead to the content of the bookmark being inserted and a
>>> hyperlink to that passage being created.
>>>
>>> I think it is a nice idea to create hyperlinks (like in Wikipedia)
>>> to
>>> certain terms that are explained elsewhere. Also if one changes
>>> one's
>>> mind about the term one can just change it at the bookmark and it is
>>> changed everywhere in the text.
>>>
>>> (I guess it is similar to creating a definition in LaTeX
>>>
>>> \def\foo{Whatever}
>>>
>>> So one can use now \foo to insert "Whatever" in the text and can
>>> change
>>> what is actually inserted in the definition. What is missing is the
>>> hyperlink part to the bookmark. So it is not exactly the same.)
>>
>>
>> Preamble:
>>
>> \usepackage{etoolbox}
>> \usepackage{hyperref}
>> \newcommand\setbookmark[2]{%
>> \csdef{bkmk@#1}{#2}%
>> \label{bkmk:#1}%
>> #2
>> }
>>
>> \newcommand\usebookmark[1]{%
>> \hyperref[bkmk:#1]{\csuse{bkmk@#1}}%
>> }
>>
>>
>> Usage:
>>
>> \setbookmark{test}{A test!}
>> marks the bookmark "test" and prints the text "a test!"
>>
>>
>> \usebookmark{test}
>> prints the text "a test!" as a hyperlink to the former occurrence.
>>
>> HTH
>> Jürgen
>>
>>
>>>
>>> Best,
>>> Daniel
>>>
>>
>



Re: Creating bookmarks based on passage in the text

2016-04-30 Thread racoon
Thanks Jürgen. I guess your reply implies that there is no special 
function for this in LyX.


A problem with the solution you posted is that it seems to work only in 
the case when the bookmark is set in a normal paragraph. Otherwise it 
seems to fail for some reason. I have attached an example.


On 30.04.2016 14:53, Jürgen Spitzmüller wrote:

Am Samstag, den 30.04.2016, 09:36 +0200 schrieb racoon:

Hi,

In word you can create bookmarks based on a passage in the text. Is
there such a feature in LyX?

So basically it would work like this:

1. You mark a passage (e.g. a word).
2. You make it a bookmark.
2. You go somewhere else and insert a cross reference top the
bookmark.
This will lead to the content of the bookmark being inserted and a
hyperlink to that passage being created.

I think it is a nice idea to create hyperlinks (like in Wikipedia)
to
certain terms that are explained elsewhere. Also if one changes
one's
mind about the term one can just change it at the bookmark and it is
changed everywhere in the text.

(I guess it is similar to creating a definition in LaTeX

\def\foo{Whatever}

So one can use now \foo to insert "Whatever" in the text and can
change
what is actually inserted in the definition. What is missing is the
hyperlink part to the bookmark. So it is not exactly the same.)



Preamble:

\usepackage{etoolbox}
\usepackage{hyperref}
\newcommand\setbookmark[2]{%
\csdef{bkmk@#1}{#2}%
\label{bkmk:#1}%
#2
}

\newcommand\usebookmark[1]{%
\hyperref[bkmk:#1]{\csuse{bkmk@#1}}%
}


Usage:

\setbookmark{test}{A test!}
marks the bookmark "test" and prints the text "a test!"


\usebookmark{test}
prints the text "a test!" as a hyperlink to the former occurrence.

HTH
Jürgen




Best,
Daniel







Bookmark in environment.lyx
Description: application/lyx


Re: Creating bookmarks based on passage in the text

2016-04-30 Thread Jürgen Spitzmüller
Am Samstag, den 30.04.2016, 09:36 +0200 schrieb racoon:
> Hi,
> 
> In word you can create bookmarks based on a passage in the text. Is 
> there such a feature in LyX?
> 
> So basically it would work like this:
> 
> 1. You mark a passage (e.g. a word).
> 2. You make it a bookmark.
> 2. You go somewhere else and insert a cross reference top the
> bookmark. 
> This will lead to the content of the bookmark being inserted and a 
> hyperlink to that passage being created.
> 
> I think it is a nice idea to create hyperlinks (like in Wikipedia)
> to 
> certain terms that are explained elsewhere. Also if one changes
> one's 
> mind about the term one can just change it at the bookmark and it is 
> changed everywhere in the text.
> 
> (I guess it is similar to creating a definition in LaTeX
> 
> \def\foo{Whatever}
> 
> So one can use now \foo to insert "Whatever" in the text and can
> change 
> what is actually inserted in the definition. What is missing is the 
> hyperlink part to the bookmark. So it is not exactly the same.)


Preamble:

\usepackage{etoolbox}
\usepackage{hyperref}
\newcommand\setbookmark[2]{%
\csdef{bkmk@#1}{#2}%
\label{bkmk:#1}%
#2
}

\newcommand\usebookmark[1]{%
\hyperref[bkmk:#1]{\csuse{bkmk@#1}}%
}


Usage:

\setbookmark{test}{A test!}
marks the bookmark "test" and prints the text "a test!"


\usebookmark{test}
prints the text "a test!" as a hyperlink to the former occurrence.

HTH
Jürgen


> 
> Best,
> Daniel
> 


Re: Creating bookmarks based on passage in the text

2016-04-30 Thread racoon

On 30.04.2016 09:59, Michael Berger wrote:



On 04/30/2016 09:36 AM, racoon wrote:

Hi,

In word you can create bookmarks based on a passage in the text. Is
there such a feature in LyX?

So basically it would work like this:

1. You mark a passage (e.g. a word).
2. You make it a bookmark.
2. You go somewhere else and insert a cross reference top the
bookmark. This will lead to the content of the bookmark being inserted
and a hyperlink to that passage being created.

I think it is a nice idea to create hyperlinks (like in Wikipedia) to
certain terms that are explained elsewhere. Also if one changes one's
mind about the term one can just change it at the bookmark and it is
changed everywhere in the text.

(I guess it is similar to creating a definition in LaTeX

\def\foo{Whatever}

So one can use now \foo to insert "Whatever" in the text and can
change what is actually inserted in the definition. What is missing is
the hyperlink part to the bookmark. So it is not exactly the same.)

Best,
Daniel

Hi Daniel,
should your last sentence taken to be a question or a statement?
Michael




Hi Michael,
Thanks for your answer. (For some reason my answer ended up being 
directly send to you that was not intended.)


It should be a statement, I think. (I am wondering why you ask this. 
Probably I am overlooking something.)


Daniel



Re: Creating bookmarks based on passage in the text

2016-04-30 Thread Michael Berger



On 04/30/2016 09:36 AM, racoon wrote:

Hi,

In word you can create bookmarks based on a passage in the text. Is 
there such a feature in LyX?


So basically it would work like this:

1. You mark a passage (e.g. a word).
2. You make it a bookmark.
2. You go somewhere else and insert a cross reference top the 
bookmark. This will lead to the content of the bookmark being inserted 
and a hyperlink to that passage being created.


I think it is a nice idea to create hyperlinks (like in Wikipedia) to 
certain terms that are explained elsewhere. Also if one changes one's 
mind about the term one can just change it at the bookmark and it is 
changed everywhere in the text.


(I guess it is similar to creating a definition in LaTeX

\def\foo{Whatever}

So one can use now \foo to insert "Whatever" in the text and can 
change what is actually inserted in the definition. What is missing is 
the hyperlink part to the bookmark. So it is not exactly the same.)


Best,
Daniel

Hi Daniel,
should your last sentence taken to be a question or a statement?
Michael



Creating bookmarks based on passage in the text

2016-04-30 Thread racoon

Hi,

In word you can create bookmarks based on a passage in the text. Is 
there such a feature in LyX?


So basically it would work like this:

1. You mark a passage (e.g. a word).
2. You make it a bookmark.
2. You go somewhere else and insert a cross reference top the bookmark. 
This will lead to the content of the bookmark being inserted and a 
hyperlink to that passage being created.


I think it is a nice idea to create hyperlinks (like in Wikipedia) to 
certain terms that are explained elsewhere. Also if one changes one's 
mind about the term one can just change it at the bookmark and it is 
changed everywhere in the text.


(I guess it is similar to creating a definition in LaTeX

\def\foo{Whatever}

So one can use now \foo to insert "Whatever" in the text and can change 
what is actually inserted in the definition. What is missing is the 
hyperlink part to the bookmark. So it is not exactly the same.)


Best,
Daniel