Redefine title for possibility of a forced line breaking in a predefined place
When we use the macro title{Some Title}
, the macro just assign the Some Text
to another internal one @title
as defined in latex.ltx
:
deftitle#1{gdef@title{#1}}
We can use the @title
in various places of document, for example, in hypersetup{pdftitle={@title}}
for pdf-meta, or in some another places of an document. For example, if title looks like
title{The World Big Idea: with small corrections}
.
The some places need to be shown as The World Big Idea:
line break here with small corrections
. But in some another places it should stand still in a single line.
How to redefine title
or possible, any other good ideas?
documentclass{article}
title{Some Title}
begin{document}
makeatletter
@title % One can use @title in different places
makeatother
makeatletter
%@title Here one need to use the same text, but with line breack between "Same" and "Tile"
Some\Title
makeatother
end{document}
titles
add a comment |
When we use the macro title{Some Title}
, the macro just assign the Some Text
to another internal one @title
as defined in latex.ltx
:
deftitle#1{gdef@title{#1}}
We can use the @title
in various places of document, for example, in hypersetup{pdftitle={@title}}
for pdf-meta, or in some another places of an document. For example, if title looks like
title{The World Big Idea: with small corrections}
.
The some places need to be shown as The World Big Idea:
line break here with small corrections
. But in some another places it should stand still in a single line.
How to redefine title
or possible, any other good ideas?
documentclass{article}
title{Some Title}
begin{document}
makeatletter
@title % One can use @title in different places
makeatother
makeatletter
%@title Here one need to use the same text, but with line breack between "Same" and "Tile"
Some\Title
makeatother
end{document}
titles
1
I guess this depends on what uses for@title
you have in mind.
– moewe
Dec 16 '18 at 15:48
@moewe I use the@title
inhypersetup{pdftitle={@title}}
. Here it shoul be in single line, but in titlepage I need to breack the line in some place.
– sergiokapone
Dec 16 '18 at 15:51
@sergiokapone Off-topichypersetup{pdftitle={@title}}
is unnecessary, the title is used per default for the pdf meta data
– samcarter
Dec 16 '18 at 15:53
@samcarter Ok, buthypersetup{pdftitle={@title}}
was just for example.
– sergiokapone
Dec 16 '18 at 15:58
2
Mhhh,@title
is one macro and it can obviously only have one definition at a time. You could write something liketitle{Some mypossiblenewline Title}
and redefine the meaning ofmypossiblenewline
from context to context. But I think it would be tricky to have one place of definition for@title
and several possible outcomes.
– moewe
Dec 16 '18 at 16:04
add a comment |
When we use the macro title{Some Title}
, the macro just assign the Some Text
to another internal one @title
as defined in latex.ltx
:
deftitle#1{gdef@title{#1}}
We can use the @title
in various places of document, for example, in hypersetup{pdftitle={@title}}
for pdf-meta, or in some another places of an document. For example, if title looks like
title{The World Big Idea: with small corrections}
.
The some places need to be shown as The World Big Idea:
line break here with small corrections
. But in some another places it should stand still in a single line.
How to redefine title
or possible, any other good ideas?
documentclass{article}
title{Some Title}
begin{document}
makeatletter
@title % One can use @title in different places
makeatother
makeatletter
%@title Here one need to use the same text, but with line breack between "Same" and "Tile"
Some\Title
makeatother
end{document}
titles
When we use the macro title{Some Title}
, the macro just assign the Some Text
to another internal one @title
as defined in latex.ltx
:
deftitle#1{gdef@title{#1}}
We can use the @title
in various places of document, for example, in hypersetup{pdftitle={@title}}
for pdf-meta, or in some another places of an document. For example, if title looks like
title{The World Big Idea: with small corrections}
.
The some places need to be shown as The World Big Idea:
line break here with small corrections
. But in some another places it should stand still in a single line.
How to redefine title
or possible, any other good ideas?
documentclass{article}
title{Some Title}
begin{document}
makeatletter
@title % One can use @title in different places
makeatother
makeatletter
%@title Here one need to use the same text, but with line breack between "Same" and "Tile"
Some\Title
makeatother
end{document}
titles
titles
edited Dec 16 '18 at 16:24
sergiokapone
asked Dec 16 '18 at 15:41
sergiokaponesergiokapone
2,434926
2,434926
1
I guess this depends on what uses for@title
you have in mind.
– moewe
Dec 16 '18 at 15:48
@moewe I use the@title
inhypersetup{pdftitle={@title}}
. Here it shoul be in single line, but in titlepage I need to breack the line in some place.
– sergiokapone
Dec 16 '18 at 15:51
@sergiokapone Off-topichypersetup{pdftitle={@title}}
is unnecessary, the title is used per default for the pdf meta data
– samcarter
Dec 16 '18 at 15:53
@samcarter Ok, buthypersetup{pdftitle={@title}}
was just for example.
– sergiokapone
Dec 16 '18 at 15:58
2
Mhhh,@title
is one macro and it can obviously only have one definition at a time. You could write something liketitle{Some mypossiblenewline Title}
and redefine the meaning ofmypossiblenewline
from context to context. But I think it would be tricky to have one place of definition for@title
and several possible outcomes.
– moewe
Dec 16 '18 at 16:04
add a comment |
1
I guess this depends on what uses for@title
you have in mind.
– moewe
Dec 16 '18 at 15:48
@moewe I use the@title
inhypersetup{pdftitle={@title}}
. Here it shoul be in single line, but in titlepage I need to breack the line in some place.
– sergiokapone
Dec 16 '18 at 15:51
@sergiokapone Off-topichypersetup{pdftitle={@title}}
is unnecessary, the title is used per default for the pdf meta data
– samcarter
Dec 16 '18 at 15:53
@samcarter Ok, buthypersetup{pdftitle={@title}}
was just for example.
– sergiokapone
Dec 16 '18 at 15:58
2
Mhhh,@title
is one macro and it can obviously only have one definition at a time. You could write something liketitle{Some mypossiblenewline Title}
and redefine the meaning ofmypossiblenewline
from context to context. But I think it would be tricky to have one place of definition for@title
and several possible outcomes.
– moewe
Dec 16 '18 at 16:04
1
1
I guess this depends on what uses for
@title
you have in mind.– moewe
Dec 16 '18 at 15:48
I guess this depends on what uses for
@title
you have in mind.– moewe
Dec 16 '18 at 15:48
@moewe I use the
@title
in hypersetup{pdftitle={@title}}
. Here it shoul be in single line, but in titlepage I need to breack the line in some place.– sergiokapone
Dec 16 '18 at 15:51
@moewe I use the
@title
in hypersetup{pdftitle={@title}}
. Here it shoul be in single line, but in titlepage I need to breack the line in some place.– sergiokapone
Dec 16 '18 at 15:51
@sergiokapone Off-topic
hypersetup{pdftitle={@title}}
is unnecessary, the title is used per default for the pdf meta data– samcarter
Dec 16 '18 at 15:53
@sergiokapone Off-topic
hypersetup{pdftitle={@title}}
is unnecessary, the title is used per default for the pdf meta data– samcarter
Dec 16 '18 at 15:53
@samcarter Ok, but
hypersetup{pdftitle={@title}}
was just for example.– sergiokapone
Dec 16 '18 at 15:58
@samcarter Ok, but
hypersetup{pdftitle={@title}}
was just for example.– sergiokapone
Dec 16 '18 at 15:58
2
2
Mhhh,
@title
is one macro and it can obviously only have one definition at a time. You could write something like title{Some mypossiblenewline Title}
and redefine the meaning of mypossiblenewline
from context to context. But I think it would be tricky to have one place of definition for @title
and several possible outcomes.– moewe
Dec 16 '18 at 16:04
Mhhh,
@title
is one macro and it can obviously only have one definition at a time. You could write something like title{Some mypossiblenewline Title}
and redefine the meaning of mypossiblenewline
from context to context. But I think it would be tricky to have one place of definition for @title
and several possible outcomes.– moewe
Dec 16 '18 at 16:04
add a comment |
3 Answers
3
active
oldest
votes
Here is a naive idea.
Use a placeholder in the definition of @title
via title
and redefine that placeholder variable as required by the context.
documentclass{article}
newcommand*{mypossiblenewline}{newline}
title{Some mypossiblenewline Title}
begin{document}
makeatletter
@title
makeatother
makeatletter
begingroup
renewcommand*{mypossiblenewline}{}
@title
endgroup
makeatother
end{document}
You could wrap that up in one command, for example
makeatletter
DeclareRobustCommand*{sergiotitlenobreak}{%
begingroup
renewcommand*{mypossiblenewline}{}%
@title
endgroup
}
DeclareRobustCommand*{sergiotitlewithbreak}{%
begingroup
renewcommand*{mypossiblenewline}{newline}%
@title
endgroup
}
makeatother
but that would not be expandable (which could be a problem depending on the context).
Yes, thank you. This is some solution of my problem.
– sergiokapone
Dec 16 '18 at 16:10
add a comment |
Save two more variables, for lack of creativity I named them realtitle
and inlinetitle
. In the second one, \
tokens are substituted with spaces, first removing spaces at either side of \
. Thus it is immaterial if you input any of
title{Some Title \ with line breaks}
title{Some Title\ with line breaks}
title{Some Title\with line breaks}
Here's the code.
documentclass{article}
usepackage{xparse}
usepackage{hyperref}
ExplSyntaxOn
RenewDocumentCommand{title}{m}
{
tl_gset:cn { @title } { #1 } % needed by maketitle
tl_gset:Nn { realtitle } { #1 }
seq_set_split:Nnn l_tmpa_seq { \ } { #1 }
tl_gset:Nx inlinetitle { seq_use:Nn l_tmpa_seq { ~ } }
}
ExplSyntaxOff
author{author}
title{Some Title \ with line breaks}
hypersetup{
pdftitle=inlinetitle
}
begin{document}
maketitle
The title of this document is ``inlinetitle''.
begin{center}
realtitle
end{center}
end{document}
You can also cope with \[<dimen>]
:
documentclass{article}
usepackage{xparse}
usepackage{hyperref}
ExplSyntaxOn
RenewDocumentCommand{title}{m}
{
tl_gset:cn { @title } { #1 } % needed by maketitle
tl_gset:Nn { realtitle } { #1 }
tl_set:Nn inlinetitle { #1 }
regex_replace_all:nnN { s* c{\}([[^]]*])+ s* } { } inlinetitle
}
ExplSyntaxOff
author{author}
title{Some Title \[1ex] with line breaks \[1ex] and added spacing}
hypersetup{
pdftitle=inlinetitle
}
begin{document}
maketitle
The title of this document is ``inlinetitle''.
begin{center}
realtitle
end{center}
end{document}
add a comment |
Different approach: instead of redefining @title
, you can use texorpdfstring
to specify two versions, one without linebreaks which will be used in the pdf meta data and one with linebreak to be displayed in the pdf
documentclass{article}
usepackage{hyperref}
title{texorpdfstring{Somenewline Title}{Some title}}
begin{document}
makeatletter
@title % One can use @title in different places
makeatother
end{document}
How can I force line bracking only one place of document, but not in others?
– sergiokapone
Dec 16 '18 at 15:49
@sergiokapone can you give an example where you want it without linebreak? You could specify an optional shorttitle
– samcarter
Dec 16 '18 at 15:51
It is hard to give an example, because in some places of document the@title
should be in one line, but in some another it should to break in predefined place. Fo example, if title looks liketitle{The World Big Idea: with small corrections}
. The some places need to be breakThe World Big Idea: \ with small corrections
– sergiokapone
Dec 16 '18 at 15:54
1
@sergiokapone If it is hard to give an example, it is also hard to answer your question. In your question you only mentioned that you need one line for the pdf meta data and this is what I covered in my answer
– samcarter
Dec 16 '18 at 15:56
@sergiokapone Off-topic: Don't use \ for line breaks
– samcarter
Dec 16 '18 at 15:57
|
show 1 more comment
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f466095%2fredefine-title-for-possibility-of-a-forced-line-breaking-in-a-predefined-place%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is a naive idea.
Use a placeholder in the definition of @title
via title
and redefine that placeholder variable as required by the context.
documentclass{article}
newcommand*{mypossiblenewline}{newline}
title{Some mypossiblenewline Title}
begin{document}
makeatletter
@title
makeatother
makeatletter
begingroup
renewcommand*{mypossiblenewline}{}
@title
endgroup
makeatother
end{document}
You could wrap that up in one command, for example
makeatletter
DeclareRobustCommand*{sergiotitlenobreak}{%
begingroup
renewcommand*{mypossiblenewline}{}%
@title
endgroup
}
DeclareRobustCommand*{sergiotitlewithbreak}{%
begingroup
renewcommand*{mypossiblenewline}{newline}%
@title
endgroup
}
makeatother
but that would not be expandable (which could be a problem depending on the context).
Yes, thank you. This is some solution of my problem.
– sergiokapone
Dec 16 '18 at 16:10
add a comment |
Here is a naive idea.
Use a placeholder in the definition of @title
via title
and redefine that placeholder variable as required by the context.
documentclass{article}
newcommand*{mypossiblenewline}{newline}
title{Some mypossiblenewline Title}
begin{document}
makeatletter
@title
makeatother
makeatletter
begingroup
renewcommand*{mypossiblenewline}{}
@title
endgroup
makeatother
end{document}
You could wrap that up in one command, for example
makeatletter
DeclareRobustCommand*{sergiotitlenobreak}{%
begingroup
renewcommand*{mypossiblenewline}{}%
@title
endgroup
}
DeclareRobustCommand*{sergiotitlewithbreak}{%
begingroup
renewcommand*{mypossiblenewline}{newline}%
@title
endgroup
}
makeatother
but that would not be expandable (which could be a problem depending on the context).
Yes, thank you. This is some solution of my problem.
– sergiokapone
Dec 16 '18 at 16:10
add a comment |
Here is a naive idea.
Use a placeholder in the definition of @title
via title
and redefine that placeholder variable as required by the context.
documentclass{article}
newcommand*{mypossiblenewline}{newline}
title{Some mypossiblenewline Title}
begin{document}
makeatletter
@title
makeatother
makeatletter
begingroup
renewcommand*{mypossiblenewline}{}
@title
endgroup
makeatother
end{document}
You could wrap that up in one command, for example
makeatletter
DeclareRobustCommand*{sergiotitlenobreak}{%
begingroup
renewcommand*{mypossiblenewline}{}%
@title
endgroup
}
DeclareRobustCommand*{sergiotitlewithbreak}{%
begingroup
renewcommand*{mypossiblenewline}{newline}%
@title
endgroup
}
makeatother
but that would not be expandable (which could be a problem depending on the context).
Here is a naive idea.
Use a placeholder in the definition of @title
via title
and redefine that placeholder variable as required by the context.
documentclass{article}
newcommand*{mypossiblenewline}{newline}
title{Some mypossiblenewline Title}
begin{document}
makeatletter
@title
makeatother
makeatletter
begingroup
renewcommand*{mypossiblenewline}{}
@title
endgroup
makeatother
end{document}
You could wrap that up in one command, for example
makeatletter
DeclareRobustCommand*{sergiotitlenobreak}{%
begingroup
renewcommand*{mypossiblenewline}{}%
@title
endgroup
}
DeclareRobustCommand*{sergiotitlewithbreak}{%
begingroup
renewcommand*{mypossiblenewline}{newline}%
@title
endgroup
}
makeatother
but that would not be expandable (which could be a problem depending on the context).
edited Dec 16 '18 at 16:16
answered Dec 16 '18 at 16:09
moewemoewe
87.5k9110335
87.5k9110335
Yes, thank you. This is some solution of my problem.
– sergiokapone
Dec 16 '18 at 16:10
add a comment |
Yes, thank you. This is some solution of my problem.
– sergiokapone
Dec 16 '18 at 16:10
Yes, thank you. This is some solution of my problem.
– sergiokapone
Dec 16 '18 at 16:10
Yes, thank you. This is some solution of my problem.
– sergiokapone
Dec 16 '18 at 16:10
add a comment |
Save two more variables, for lack of creativity I named them realtitle
and inlinetitle
. In the second one, \
tokens are substituted with spaces, first removing spaces at either side of \
. Thus it is immaterial if you input any of
title{Some Title \ with line breaks}
title{Some Title\ with line breaks}
title{Some Title\with line breaks}
Here's the code.
documentclass{article}
usepackage{xparse}
usepackage{hyperref}
ExplSyntaxOn
RenewDocumentCommand{title}{m}
{
tl_gset:cn { @title } { #1 } % needed by maketitle
tl_gset:Nn { realtitle } { #1 }
seq_set_split:Nnn l_tmpa_seq { \ } { #1 }
tl_gset:Nx inlinetitle { seq_use:Nn l_tmpa_seq { ~ } }
}
ExplSyntaxOff
author{author}
title{Some Title \ with line breaks}
hypersetup{
pdftitle=inlinetitle
}
begin{document}
maketitle
The title of this document is ``inlinetitle''.
begin{center}
realtitle
end{center}
end{document}
You can also cope with \[<dimen>]
:
documentclass{article}
usepackage{xparse}
usepackage{hyperref}
ExplSyntaxOn
RenewDocumentCommand{title}{m}
{
tl_gset:cn { @title } { #1 } % needed by maketitle
tl_gset:Nn { realtitle } { #1 }
tl_set:Nn inlinetitle { #1 }
regex_replace_all:nnN { s* c{\}([[^]]*])+ s* } { } inlinetitle
}
ExplSyntaxOff
author{author}
title{Some Title \[1ex] with line breaks \[1ex] and added spacing}
hypersetup{
pdftitle=inlinetitle
}
begin{document}
maketitle
The title of this document is ``inlinetitle''.
begin{center}
realtitle
end{center}
end{document}
add a comment |
Save two more variables, for lack of creativity I named them realtitle
and inlinetitle
. In the second one, \
tokens are substituted with spaces, first removing spaces at either side of \
. Thus it is immaterial if you input any of
title{Some Title \ with line breaks}
title{Some Title\ with line breaks}
title{Some Title\with line breaks}
Here's the code.
documentclass{article}
usepackage{xparse}
usepackage{hyperref}
ExplSyntaxOn
RenewDocumentCommand{title}{m}
{
tl_gset:cn { @title } { #1 } % needed by maketitle
tl_gset:Nn { realtitle } { #1 }
seq_set_split:Nnn l_tmpa_seq { \ } { #1 }
tl_gset:Nx inlinetitle { seq_use:Nn l_tmpa_seq { ~ } }
}
ExplSyntaxOff
author{author}
title{Some Title \ with line breaks}
hypersetup{
pdftitle=inlinetitle
}
begin{document}
maketitle
The title of this document is ``inlinetitle''.
begin{center}
realtitle
end{center}
end{document}
You can also cope with \[<dimen>]
:
documentclass{article}
usepackage{xparse}
usepackage{hyperref}
ExplSyntaxOn
RenewDocumentCommand{title}{m}
{
tl_gset:cn { @title } { #1 } % needed by maketitle
tl_gset:Nn { realtitle } { #1 }
tl_set:Nn inlinetitle { #1 }
regex_replace_all:nnN { s* c{\}([[^]]*])+ s* } { } inlinetitle
}
ExplSyntaxOff
author{author}
title{Some Title \[1ex] with line breaks \[1ex] and added spacing}
hypersetup{
pdftitle=inlinetitle
}
begin{document}
maketitle
The title of this document is ``inlinetitle''.
begin{center}
realtitle
end{center}
end{document}
add a comment |
Save two more variables, for lack of creativity I named them realtitle
and inlinetitle
. In the second one, \
tokens are substituted with spaces, first removing spaces at either side of \
. Thus it is immaterial if you input any of
title{Some Title \ with line breaks}
title{Some Title\ with line breaks}
title{Some Title\with line breaks}
Here's the code.
documentclass{article}
usepackage{xparse}
usepackage{hyperref}
ExplSyntaxOn
RenewDocumentCommand{title}{m}
{
tl_gset:cn { @title } { #1 } % needed by maketitle
tl_gset:Nn { realtitle } { #1 }
seq_set_split:Nnn l_tmpa_seq { \ } { #1 }
tl_gset:Nx inlinetitle { seq_use:Nn l_tmpa_seq { ~ } }
}
ExplSyntaxOff
author{author}
title{Some Title \ with line breaks}
hypersetup{
pdftitle=inlinetitle
}
begin{document}
maketitle
The title of this document is ``inlinetitle''.
begin{center}
realtitle
end{center}
end{document}
You can also cope with \[<dimen>]
:
documentclass{article}
usepackage{xparse}
usepackage{hyperref}
ExplSyntaxOn
RenewDocumentCommand{title}{m}
{
tl_gset:cn { @title } { #1 } % needed by maketitle
tl_gset:Nn { realtitle } { #1 }
tl_set:Nn inlinetitle { #1 }
regex_replace_all:nnN { s* c{\}([[^]]*])+ s* } { } inlinetitle
}
ExplSyntaxOff
author{author}
title{Some Title \[1ex] with line breaks \[1ex] and added spacing}
hypersetup{
pdftitle=inlinetitle
}
begin{document}
maketitle
The title of this document is ``inlinetitle''.
begin{center}
realtitle
end{center}
end{document}
Save two more variables, for lack of creativity I named them realtitle
and inlinetitle
. In the second one, \
tokens are substituted with spaces, first removing spaces at either side of \
. Thus it is immaterial if you input any of
title{Some Title \ with line breaks}
title{Some Title\ with line breaks}
title{Some Title\with line breaks}
Here's the code.
documentclass{article}
usepackage{xparse}
usepackage{hyperref}
ExplSyntaxOn
RenewDocumentCommand{title}{m}
{
tl_gset:cn { @title } { #1 } % needed by maketitle
tl_gset:Nn { realtitle } { #1 }
seq_set_split:Nnn l_tmpa_seq { \ } { #1 }
tl_gset:Nx inlinetitle { seq_use:Nn l_tmpa_seq { ~ } }
}
ExplSyntaxOff
author{author}
title{Some Title \ with line breaks}
hypersetup{
pdftitle=inlinetitle
}
begin{document}
maketitle
The title of this document is ``inlinetitle''.
begin{center}
realtitle
end{center}
end{document}
You can also cope with \[<dimen>]
:
documentclass{article}
usepackage{xparse}
usepackage{hyperref}
ExplSyntaxOn
RenewDocumentCommand{title}{m}
{
tl_gset:cn { @title } { #1 } % needed by maketitle
tl_gset:Nn { realtitle } { #1 }
tl_set:Nn inlinetitle { #1 }
regex_replace_all:nnN { s* c{\}([[^]]*])+ s* } { } inlinetitle
}
ExplSyntaxOff
author{author}
title{Some Title \[1ex] with line breaks \[1ex] and added spacing}
hypersetup{
pdftitle=inlinetitle
}
begin{document}
maketitle
The title of this document is ``inlinetitle''.
begin{center}
realtitle
end{center}
end{document}
edited Dec 16 '18 at 16:54
answered Dec 16 '18 at 16:38
egregegreg
711k8618913174
711k8618913174
add a comment |
add a comment |
Different approach: instead of redefining @title
, you can use texorpdfstring
to specify two versions, one without linebreaks which will be used in the pdf meta data and one with linebreak to be displayed in the pdf
documentclass{article}
usepackage{hyperref}
title{texorpdfstring{Somenewline Title}{Some title}}
begin{document}
makeatletter
@title % One can use @title in different places
makeatother
end{document}
How can I force line bracking only one place of document, but not in others?
– sergiokapone
Dec 16 '18 at 15:49
@sergiokapone can you give an example where you want it without linebreak? You could specify an optional shorttitle
– samcarter
Dec 16 '18 at 15:51
It is hard to give an example, because in some places of document the@title
should be in one line, but in some another it should to break in predefined place. Fo example, if title looks liketitle{The World Big Idea: with small corrections}
. The some places need to be breakThe World Big Idea: \ with small corrections
– sergiokapone
Dec 16 '18 at 15:54
1
@sergiokapone If it is hard to give an example, it is also hard to answer your question. In your question you only mentioned that you need one line for the pdf meta data and this is what I covered in my answer
– samcarter
Dec 16 '18 at 15:56
@sergiokapone Off-topic: Don't use \ for line breaks
– samcarter
Dec 16 '18 at 15:57
|
show 1 more comment
Different approach: instead of redefining @title
, you can use texorpdfstring
to specify two versions, one without linebreaks which will be used in the pdf meta data and one with linebreak to be displayed in the pdf
documentclass{article}
usepackage{hyperref}
title{texorpdfstring{Somenewline Title}{Some title}}
begin{document}
makeatletter
@title % One can use @title in different places
makeatother
end{document}
How can I force line bracking only one place of document, but not in others?
– sergiokapone
Dec 16 '18 at 15:49
@sergiokapone can you give an example where you want it without linebreak? You could specify an optional shorttitle
– samcarter
Dec 16 '18 at 15:51
It is hard to give an example, because in some places of document the@title
should be in one line, but in some another it should to break in predefined place. Fo example, if title looks liketitle{The World Big Idea: with small corrections}
. The some places need to be breakThe World Big Idea: \ with small corrections
– sergiokapone
Dec 16 '18 at 15:54
1
@sergiokapone If it is hard to give an example, it is also hard to answer your question. In your question you only mentioned that you need one line for the pdf meta data and this is what I covered in my answer
– samcarter
Dec 16 '18 at 15:56
@sergiokapone Off-topic: Don't use \ for line breaks
– samcarter
Dec 16 '18 at 15:57
|
show 1 more comment
Different approach: instead of redefining @title
, you can use texorpdfstring
to specify two versions, one without linebreaks which will be used in the pdf meta data and one with linebreak to be displayed in the pdf
documentclass{article}
usepackage{hyperref}
title{texorpdfstring{Somenewline Title}{Some title}}
begin{document}
makeatletter
@title % One can use @title in different places
makeatother
end{document}
Different approach: instead of redefining @title
, you can use texorpdfstring
to specify two versions, one without linebreaks which will be used in the pdf meta data and one with linebreak to be displayed in the pdf
documentclass{article}
usepackage{hyperref}
title{texorpdfstring{Somenewline Title}{Some title}}
begin{document}
makeatletter
@title % One can use @title in different places
makeatother
end{document}
answered Dec 16 '18 at 15:44
samcartersamcarter
86.6k795277
86.6k795277
How can I force line bracking only one place of document, but not in others?
– sergiokapone
Dec 16 '18 at 15:49
@sergiokapone can you give an example where you want it without linebreak? You could specify an optional shorttitle
– samcarter
Dec 16 '18 at 15:51
It is hard to give an example, because in some places of document the@title
should be in one line, but in some another it should to break in predefined place. Fo example, if title looks liketitle{The World Big Idea: with small corrections}
. The some places need to be breakThe World Big Idea: \ with small corrections
– sergiokapone
Dec 16 '18 at 15:54
1
@sergiokapone If it is hard to give an example, it is also hard to answer your question. In your question you only mentioned that you need one line for the pdf meta data and this is what I covered in my answer
– samcarter
Dec 16 '18 at 15:56
@sergiokapone Off-topic: Don't use \ for line breaks
– samcarter
Dec 16 '18 at 15:57
|
show 1 more comment
How can I force line bracking only one place of document, but not in others?
– sergiokapone
Dec 16 '18 at 15:49
@sergiokapone can you give an example where you want it without linebreak? You could specify an optional shorttitle
– samcarter
Dec 16 '18 at 15:51
It is hard to give an example, because in some places of document the@title
should be in one line, but in some another it should to break in predefined place. Fo example, if title looks liketitle{The World Big Idea: with small corrections}
. The some places need to be breakThe World Big Idea: \ with small corrections
– sergiokapone
Dec 16 '18 at 15:54
1
@sergiokapone If it is hard to give an example, it is also hard to answer your question. In your question you only mentioned that you need one line for the pdf meta data and this is what I covered in my answer
– samcarter
Dec 16 '18 at 15:56
@sergiokapone Off-topic: Don't use \ for line breaks
– samcarter
Dec 16 '18 at 15:57
How can I force line bracking only one place of document, but not in others?
– sergiokapone
Dec 16 '18 at 15:49
How can I force line bracking only one place of document, but not in others?
– sergiokapone
Dec 16 '18 at 15:49
@sergiokapone can you give an example where you want it without linebreak? You could specify an optional shorttitle
– samcarter
Dec 16 '18 at 15:51
@sergiokapone can you give an example where you want it without linebreak? You could specify an optional shorttitle
– samcarter
Dec 16 '18 at 15:51
It is hard to give an example, because in some places of document the
@title
should be in one line, but in some another it should to break in predefined place. Fo example, if title looks like title{The World Big Idea: with small corrections}
. The some places need to be break The World Big Idea: \ with small corrections
– sergiokapone
Dec 16 '18 at 15:54
It is hard to give an example, because in some places of document the
@title
should be in one line, but in some another it should to break in predefined place. Fo example, if title looks like title{The World Big Idea: with small corrections}
. The some places need to be break The World Big Idea: \ with small corrections
– sergiokapone
Dec 16 '18 at 15:54
1
1
@sergiokapone If it is hard to give an example, it is also hard to answer your question. In your question you only mentioned that you need one line for the pdf meta data and this is what I covered in my answer
– samcarter
Dec 16 '18 at 15:56
@sergiokapone If it is hard to give an example, it is also hard to answer your question. In your question you only mentioned that you need one line for the pdf meta data and this is what I covered in my answer
– samcarter
Dec 16 '18 at 15:56
@sergiokapone Off-topic: Don't use \ for line breaks
– samcarter
Dec 16 '18 at 15:57
@sergiokapone Off-topic: Don't use \ for line breaks
– samcarter
Dec 16 '18 at 15:57
|
show 1 more comment
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f466095%2fredefine-title-for-possibility-of-a-forced-line-breaking-in-a-predefined-place%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I guess this depends on what uses for
@title
you have in mind.– moewe
Dec 16 '18 at 15:48
@moewe I use the
@title
inhypersetup{pdftitle={@title}}
. Here it shoul be in single line, but in titlepage I need to breack the line in some place.– sergiokapone
Dec 16 '18 at 15:51
@sergiokapone Off-topic
hypersetup{pdftitle={@title}}
is unnecessary, the title is used per default for the pdf meta data– samcarter
Dec 16 '18 at 15:53
@samcarter Ok, but
hypersetup{pdftitle={@title}}
was just for example.– sergiokapone
Dec 16 '18 at 15:58
2
Mhhh,
@title
is one macro and it can obviously only have one definition at a time. You could write something liketitle{Some mypossiblenewline Title}
and redefine the meaning ofmypossiblenewline
from context to context. But I think it would be tricky to have one place of definition for@title
and several possible outcomes.– moewe
Dec 16 '18 at 16:04