Redefine title for possibility of a forced line breaking in a predefined place











up vote
1
down vote

favorite












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}









share|improve this question




















  • 1




    I guess this depends on what uses for @title you have in mind.
    – moewe
    2 hours ago










  • @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
    2 hours ago










  • @sergiokapone Off-topichypersetup{pdftitle={@title}} is unnecessary, the title is used per default for the pdf meta data
    – samcarter
    2 hours ago










  • @samcarter Ok, but hypersetup{pdftitle={@title}} was just for example.
    – sergiokapone
    2 hours ago






  • 1




    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
    2 hours ago















up vote
1
down vote

favorite












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}









share|improve this question




















  • 1




    I guess this depends on what uses for @title you have in mind.
    – moewe
    2 hours ago










  • @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
    2 hours ago










  • @sergiokapone Off-topichypersetup{pdftitle={@title}} is unnecessary, the title is used per default for the pdf meta data
    – samcarter
    2 hours ago










  • @samcarter Ok, but hypersetup{pdftitle={@title}} was just for example.
    – sergiokapone
    2 hours ago






  • 1




    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
    2 hours ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











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}









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago

























asked 2 hours ago









sergiokapone

2,424926




2,424926








  • 1




    I guess this depends on what uses for @title you have in mind.
    – moewe
    2 hours ago










  • @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
    2 hours ago










  • @sergiokapone Off-topichypersetup{pdftitle={@title}} is unnecessary, the title is used per default for the pdf meta data
    – samcarter
    2 hours ago










  • @samcarter Ok, but hypersetup{pdftitle={@title}} was just for example.
    – sergiokapone
    2 hours ago






  • 1




    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
    2 hours ago














  • 1




    I guess this depends on what uses for @title you have in mind.
    – moewe
    2 hours ago










  • @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
    2 hours ago










  • @sergiokapone Off-topichypersetup{pdftitle={@title}} is unnecessary, the title is used per default for the pdf meta data
    – samcarter
    2 hours ago










  • @samcarter Ok, but hypersetup{pdftitle={@title}} was just for example.
    – sergiokapone
    2 hours ago






  • 1




    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
    2 hours ago








1




1




I guess this depends on what uses for @title you have in mind.
– moewe
2 hours ago




I guess this depends on what uses for @title you have in mind.
– moewe
2 hours ago












@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
2 hours ago




@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
2 hours ago












@sergiokapone Off-topichypersetup{pdftitle={@title}} is unnecessary, the title is used per default for the pdf meta data
– samcarter
2 hours ago




@sergiokapone Off-topichypersetup{pdftitle={@title}} is unnecessary, the title is used per default for the pdf meta data
– samcarter
2 hours ago












@samcarter Ok, but hypersetup{pdftitle={@title}} was just for example.
– sergiokapone
2 hours ago




@samcarter Ok, but hypersetup{pdftitle={@title}} was just for example.
– sergiokapone
2 hours ago




1




1




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
2 hours ago




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
2 hours ago










3 Answers
3






active

oldest

votes

















up vote
2
down vote



accepted










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).






share|improve this answer























  • Yes, thank you. This is some solution of my problem.
    – sergiokapone
    2 hours ago


















up vote
2
down vote













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}


enter image description here



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}


enter image description here






share|improve this answer






























    up vote
    1
    down vote













    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}





    share|improve this answer





















    • How can I force line bracking only one place of document, but not in others?
      – sergiokapone
      2 hours ago












    • @sergiokapone can you give an example where you want it without linebreak? You could specify an optional shorttitle
      – samcarter
      2 hours ago












    • 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
      2 hours ago








    • 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
      2 hours ago










    • @sergiokapone Off-topic: Don't use \ for line breaks
      – samcarter
      2 hours ago











    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',
    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
    });


    }
    });














    draft saved

    draft discarded


















    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








    up vote
    2
    down vote



    accepted










    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).






    share|improve this answer























    • Yes, thank you. This is some solution of my problem.
      – sergiokapone
      2 hours ago















    up vote
    2
    down vote



    accepted










    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).






    share|improve this answer























    • Yes, thank you. This is some solution of my problem.
      – sergiokapone
      2 hours ago













    up vote
    2
    down vote



    accepted







    up vote
    2
    down vote



    accepted






    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).






    share|improve this answer














    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).







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 2 hours ago

























    answered 2 hours ago









    moewe

    85k9108327




    85k9108327












    • Yes, thank you. This is some solution of my problem.
      – sergiokapone
      2 hours ago


















    • Yes, thank you. This is some solution of my problem.
      – sergiokapone
      2 hours ago
















    Yes, thank you. This is some solution of my problem.
    – sergiokapone
    2 hours ago




    Yes, thank you. This is some solution of my problem.
    – sergiokapone
    2 hours ago










    up vote
    2
    down vote













    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}


    enter image description here



    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}


    enter image description here






    share|improve this answer



























      up vote
      2
      down vote













      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}


      enter image description here



      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}


      enter image description here






      share|improve this answer

























        up vote
        2
        down vote










        up vote
        2
        down vote









        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}


        enter image description here



        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}


        enter image description here






        share|improve this answer














        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}


        enter image description here



        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}


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 1 hour ago

























        answered 1 hour ago









        egreg

        705k8618763155




        705k8618763155






















            up vote
            1
            down vote













            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}





            share|improve this answer





















            • How can I force line bracking only one place of document, but not in others?
              – sergiokapone
              2 hours ago












            • @sergiokapone can you give an example where you want it without linebreak? You could specify an optional shorttitle
              – samcarter
              2 hours ago












            • 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
              2 hours ago








            • 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
              2 hours ago










            • @sergiokapone Off-topic: Don't use \ for line breaks
              – samcarter
              2 hours ago















            up vote
            1
            down vote













            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}





            share|improve this answer





















            • How can I force line bracking only one place of document, but not in others?
              – sergiokapone
              2 hours ago












            • @sergiokapone can you give an example where you want it without linebreak? You could specify an optional shorttitle
              – samcarter
              2 hours ago












            • 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
              2 hours ago








            • 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
              2 hours ago










            • @sergiokapone Off-topic: Don't use \ for line breaks
              – samcarter
              2 hours ago













            up vote
            1
            down vote










            up vote
            1
            down vote









            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}





            share|improve this answer












            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}






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 2 hours ago









            samcarter

            84k794270




            84k794270












            • How can I force line bracking only one place of document, but not in others?
              – sergiokapone
              2 hours ago












            • @sergiokapone can you give an example where you want it without linebreak? You could specify an optional shorttitle
              – samcarter
              2 hours ago












            • 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
              2 hours ago








            • 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
              2 hours ago










            • @sergiokapone Off-topic: Don't use \ for line breaks
              – samcarter
              2 hours ago


















            • How can I force line bracking only one place of document, but not in others?
              – sergiokapone
              2 hours ago












            • @sergiokapone can you give an example where you want it without linebreak? You could specify an optional shorttitle
              – samcarter
              2 hours ago












            • 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
              2 hours ago








            • 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
              2 hours ago










            • @sergiokapone Off-topic: Don't use \ for line breaks
              – samcarter
              2 hours ago
















            How can I force line bracking only one place of document, but not in others?
            – sergiokapone
            2 hours ago






            How can I force line bracking only one place of document, but not in others?
            – sergiokapone
            2 hours ago














            @sergiokapone can you give an example where you want it without linebreak? You could specify an optional shorttitle
            – samcarter
            2 hours ago






            @sergiokapone can you give an example where you want it without linebreak? You could specify an optional shorttitle
            – samcarter
            2 hours ago














            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
            2 hours ago






            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
            2 hours ago






            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
            2 hours ago




            @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
            2 hours ago












            @sergiokapone Off-topic: Don't use \ for line breaks
            – samcarter
            2 hours ago




            @sergiokapone Off-topic: Don't use \ for line breaks
            – samcarter
            2 hours ago


















            draft saved

            draft discarded




















































            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Ellipse (mathématiques)

            Quarter-circle Tiles

            Mont Emei