• (LaTeX) This doesn't work -- \mbox{ First Line \\ Second Line}

    From HenHanna@HenHanna@devnull.tb to comp.text.tex,de.comp.text.pdf,de.comp.text.tex,comp.text.pdf,sci.lang on Thu Jul 18 22:31:29 2024
    From Newsgroup: comp.text.pdf

    i want 2 lines to stay together... How do i do it?

    This apparently doesn't work.

    \mbox{ First Line \\
    Second Line}



    ___________________________
    in Comp.Text.Tex ... i only see CTAN (update) announcements

    can i ask LaTeX questions?
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Sirius@sirius@trudheim.com to comp.text.pdf on Fri Jul 19 09:20:13 2024
    From Newsgroup: comp.text.pdf

    On tor, 2024/07/18 at 22:31:29 -0700, HenHanna wrote:
    i want 2 lines to stay together... How do i do it?

    This apparently doesn't work.

    \mbox{ First Line \\
    Second Line}

    WFM.

    cat test.tex
    \documentclass[11pt,twoside,a4paper]{article}%
    \begin{document}

    \mbox{ Line1 \\
    Line2 }

    \end{document}
    latex test.tex
    This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) (preloaded format=latex)
    restricted \write18 enabled.
    entering extended mode
    (./test.tex
    LaTeX2e <2024-06-01> patch level 2
    L3 programming layer <2024-05-27> (/usr/local/texlive/2024/texmf-dist/tex/latex/base/article.cls
    Document Class: article 2024/02/08 v1.4n Standard LaTeX document class (/usr/local/texlive/2024/texmf-dist/tex/latex/base/size11.clo)) (/usr/local/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-dvips.def) (./test.aux)
    [1] (./test.aux) )
    Output written on test.dvi (1 page, 256 bytes).
    Transcript written on test.log.
    xdvi test.dvi

    Shows "Line1 Line2" on the page.

    https://tex.stackexchange.com/questions/146909/what-does-mbox-do
    --
    Kind regards,

    /S
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Ulrich D i e z@ud.usenetcorrespondence@web.de to de.comp.text.pdf,comp.text.pdf,sci.lang on Fri Jul 19 15:02:19 2024
    From Newsgroup: comp.text.pdf

    [Follow-up to: comp.text.tex]

    HenHanna wrote:

    i want 2 lines to stay together... How do i do it?

    This apparently doesn't work.

    \mbox{ First Line \\
    Second Line}

    [ de.comp.pdf and de.comp.tex actually are German-language newsgroups. ]

    \mbox creates a box.

    TeX switches the typesetting-mode to "restricted horizontal mode" for
    creating the content of the box.
    TeX switches the typesetting-mode to "horizontal mode" for placing the
    created box into the surrounding text.

    The further typesetting-mode is the typesetting-mode where TeX does no line-breaking at all but creates a box where material is typeset horizontally/from left to right.
    The latter typesetting-mode is the typesetting-mode where TeX creates paragraphs and hereby breaks text into lines automatically.

    The circumstance that the content of the box produced by \mbox is
    typeset in restricted horizontal mode implies that no things are done
    that concern vertical adjustment as is the case, e.g., with line-breaking.
    Thus no line-breaking is done with things that are typeset in the typesetting-mode "restricted horizontal mode".

    Different commands for producing boxes and switching the typesettig-mode
    when placing them into the document's surrounding text are explained at
    Tex - LaTeX Stack Exchange - question "What are the different kinds of
    boxes in (La)TeX?":
    https://tex.stackexchange.com/a/83936


    With your scenario I suggest placing two \hboxes holding single lines of
    text into \vtop or \vcenter or \vbox. Due to \vtop/\vcenter/\vbox the
    single \hboxes are typeset in internal vertical mode, i.e. atop each other.

    The box itself, whose content consists of the two \hboxes that are
    typeset atop each other, is to be placed into the surrounding text.

    With \vtop the baseline of the first line/the baseline of the top line
    of that box itself is aligned with the baseline of the line of the
    surrounding text which TeX is about to produce.
    With \vbox the baseline of the last line/the baseline of the bottom line
    of that box itself is aligned with the baseline of the line of the
    surrounding text which TeX is about to produce.
    With \vcenter the vertical center of that box itself is aligned with the math-axis of the line of the surrounding text which TeX is about to
    produce. (The math axis of a line of text, simplified speaking, is the
    vertical position where in the line of text in question the bar of a
    fraction would occur.)
    Although the box produced by `\vcenter` is typeset in internal vertical
    mode (where you can use \hbox{...} for having Tex switch to restricted horizontal mode), you need to have TeX to switch to math-mode for
    placing that box into the line of ttext of the surrounding text.



    \documentclass {article}

    \begin{document}

    Text
    \fbox{%
    \vtop{%
    \hbox{First Line}%
    \hbox{Second Line}%
    }%
    } Text

    Text
    \fbox{%
    $\vcenter{%
    \hbox{First Line}%
    \hbox{Second Line}%
    }$%
    } Text

    Text
    \fbox{%
    \vbox{%
    \hbox{First Line}%
    \hbox{Second Line}%
    }%
    } Text

    \end{document}



    ___________________________
    in Comp.Text.Tex ... i only see CTAN (update) announcements

    can i ask LaTeX questions?

    Yes, of course you can ask questions related to LaTeX at comp.text.tex.

    The traffic at comp.text.tex has reduced over the years because many
    people nowadays ask their LaTeX-related questions at
    TeX - LaTeX Stack Exchange: https://tex.stackexchange.com/ .

    Many of the regulars of comp.text.tex and many developers of LaTeX
    packages and members of the LaTeX Project Team also are at
    TeX - LaTeX Stack Exchange.

    TeX - LaTeX Stack Exchange in my humble opinion is much more welcoming
    than other communities of the Stack Exchange netwok. Also the
    downvoting-policy is different from that of many other communities of
    the Stack Exchange netwok: At TeX - LaTeX Stack Exchange people are
    rather reluctant in the matter of downvoting because a harsh
    downvoting-policy would scare off people unnecessarily.

    However, TeX - LaTeX Stack Exchange is a question-answer platform and
    not intended for dialogue while when starting out with LaTeX, you might
    like to have the opportunity to have dialogues and ask questions that
    are related to answers you have received. There is a chat at Tex - LaTeX
    Stack Exchange also, which is sort of separate from the question-answer-thingie, but I think I think comp.text.tex is more
    suitable for this.

    Sincerely

    Ulrich
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Jeff Barnett@jbb@notatt.com to comp.text.tex,de.comp.text.pdf,de.comp.text.tex,comp.text.pdf,sci.lang on Fri Jul 19 21:41:37 2024
    From Newsgroup: comp.text.pdf

    On 7/18/2024 11:31 PM, HenHanna wrote:
    i want 2 lines to stay together... How do i do it?

    This apparently doesn't work.

    -a-a-a-a-a-a-a-a-a-a-a \mbox{ First Line \\
    -a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a Second Line}



    ___________________________
    in Comp.Text.Tex-a-a ...-a i only see CTAN (update) announcements

    -a-a-a-a-a-a-a-a-a-a-a can i ask-a-a LaTeX-a questions?

    Look up the environment minipage.
    --
    Jeff Barnett

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Axel Berger@Spam@Berger-Odenthal.De to comp.text.tex,de.comp.text.pdf,de.comp.text.tex,comp.text.pdf,sci.lang on Sat Jul 20 09:37:05 2024
    From Newsgroup: comp.text.pdf

    Jeff Barnett wrote:
    Look up the environment minipage.
    Or in this case perhaps parbox
    -- />\ No | Dipl.-Ing. F. Axel Berger Tel: +49/ 221/ 7771 8067
    \ / HTML | Roald-Amundsen-Stra#e 2a Fax: +49/ 221/ 7771 8069
    aX in | D-50829 K%ln-Ossendorf http://berger-odenthal.de
    / \ Mail | -- No unannounced, large, binary attachments, please! --
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Ulrich D i e z@ud.usenetcorrespondence@web.de to de.comp.text.pdf,comp.text.pdf,sci.lang on Sat Jul 20 14:42:04 2024
    From Newsgroup: comp.text.pdf

    [Followup-To: comp.text.tex]

    Axel Berger wrote:

    Jeff Barnett wrote:
    Look up the environment minipage.

    Or in this case perhaps parbox

    In case you want the box with the first and the second line to have the
    natural width of the widest of the two lines, minipage-environment and \parbox-command, where you are to specify the desired width explicitly,
    might turn out cumbersome.

    Sincerely

    Ulrich
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Peter Flynn@peter@silmaril.ie to comp.text.tex,de.comp.text.pdf,de.comp.text.tex,comp.text.pdf,sci.lang on Wed Jul 24 10:31:34 2024
    From Newsgroup: comp.text.pdf

    On 19/07/2024 06:31, HenHanna wrote:
    i want 2 lines to stay together... How do i do it?

    This apparently doesn't work.

    -a-a-a-a-a-a-a-a-a-a-a \mbox{ First Line \\
    -a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a Second Line}

    That's because \\ is for prematurely ending a line, not for combining them.

    It's also used (differently) in tabular setting to signal the end of a row.

    Can you explain what you want to do, with a worked example?
    "want 2 lines to stay together" doesn't give enough information.

    Peter

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Antonio Marques@no_email@invalid.invalid to sci.lang,comp.text.tex,de.comp.text.pdf,de.comp.text.tex,comp.text.pdf on Wed Jul 24 14:02:03 2024
    From Newsgroup: comp.text.pdf

    Peter Flynn <peter@silmaril.ie> wrote:
    On 19/07/2024 06:31, HenHanna wrote:
    i want 2 lines to stay together... How do i do it?

    This apparently doesn't work.

    -a-a-a-a-a-a-a-a-a-a-a \mbox{ First Line \\
    -a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a Second Line}

    That's because \\ is for prematurely ending a line, not for combining them.

    It's also used (differently) in tabular setting to signal the end of a row.

    Can you explain what you want to do, with a worked example?
    "want 2 lines to stay together" doesn't give enough information.


    It's very difficult to get information out of the OP, but from what I've
    seen elsewhere the main issue was widow / orphan control.

    (That would indicate that anything focusing on those specific two lines is wrong from the start, as layout should work automatically before needing to
    be manual.)

    Not having touched latex for 20 years now, I have no idea where to look,
    but I'm reasonably sure it shouldn't be difficult.

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Eberhard W Lisse@nospam@lisse.NA to comp.text.tex,de.comp.text.pdf,de.comp.text.tex,comp.text.pdf,sci.lang on Thu Jul 25 17:37:36 2024
    From Newsgroup: comp.text.pdf

    I don't think crossposting to 5 groups two of which not in English will
    help.

    el

    On 19/07/2024 07:31, HenHanna wrote:
    i want 2 lines to stay together... How do i do it?

    [...]
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From HenHanna@HenHanna@devnull.tb to comp.text.tex,de.comp.text.pdf,de.comp.text.tex,comp.text.pdf,sci.lang on Thu Jul 25 12:00:29 2024
    From Newsgroup: comp.text.pdf



    On 7/25/2024 8:37 AM, Eberhard W Lisse wrote:
    I don't think crossposting to 5 groups two of which not in English will
    help.

    el

    On 19/07/2024 07:31, HenHanna wrote:
    i want 2 lines to stay together... How do i do it?

    [...]


    if i want 2 words to stay together... First~Second
    (and/or \mbox{...} )
    Shouldn't there be an easy way to do that for 2 lines?



    actually... i like studying German (and French)...
    so i wouldn't mind getting a short response in German.



    Fritzchen geht traurig zur Mama: "Mama! Nie glaubt mir jemand etwas!"
    "Nein Bua! Des glaub ich Dir jetzt gar nicht!"


    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Ulrich D i e z@ud.usenetcorrespondence@web.de to de.comp.text.pdf,comp.text.pdf,sci.lang on Thu Jul 25 22:51:18 2024
    From Newsgroup: comp.text.pdf

    [Followup-To: comp.text.tex]

    HenHanna wrote:

    On 7/25/2024 8:37 AM, Eberhard W Lisse wrote:
    I don't think crossposting to 5 groups two of which not in English will
    help.

    el

    On 19/07/2024 07:31, HenHanna wrote:
    i want 2 lines to stay together... How do i do it?

    [...]


    if i want 2 words to stay together... First~Second
    (and/or \mbox{...} )
    Shouldn't there be an easy way to do that for 2 lines?

    If you want to avoid clubs and/or widows while TeX is in horizontal mpde
    where it does the line-breaking for you, you can do

    \widowpenalty=10000
    \clubpenalty)10000

    But when TeX is in the situation of having to choose between several
    infinitely bad possibilities of page-breaking it might choose the one
    where you get a widow or a club anyway.

    If you want lines of an entire paragraph to not be broken across pages,
    with LaTeX put that paragraph into a minipage environment or into a
    \parbox and specify, e.g., the width \textwidth or \linewidth.With
    LaTeX there is also an environment samepage.

    With plain-TeX you can put that paragraph into a \vbox. Inside the \vbox
    you may need to say s.th. like

    \hsize=<width of lines of text inside the \vbox when TeX does the
    line-breaking automatically>

    Sincerely

    Ulrich
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Carlos E.R.@robin_listas@es.invalid to comp.text.pdf on Sat Jul 27 23:54:26 2024
    From Newsgroup: comp.text.pdf

    On 2024-07-19 09:20, Sirius wrote:
    On tor, 2024/07/18 at 22:31:29 -0700, HenHanna wrote:
    i want 2 lines to stay together... How do i do it?

    This apparently doesn't work.

    \mbox{ First Line \\
    Second Line}

    WFM.

    cat test.tex
    \documentclass[11pt,twoside,a4paper]{article}%
    \begin{document}

    \mbox{ Line1 \\
    Line2 }

    \end{document}
    latex test.tex
    This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) (preloaded format=latex)
    restricted \write18 enabled.
    entering extended mode
    (./test.tex
    LaTeX2e <2024-06-01> patch level 2
    L3 programming layer <2024-05-27> (/usr/local/texlive/2024/texmf-dist/tex/latex/base/article.cls
    Document Class: article 2024/02/08 v1.4n Standard LaTeX document class (/usr/local/texlive/2024/texmf-dist/tex/latex/base/size11.clo)) (/usr/local/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-dvips.def) (./test.aux)
    [1] (./test.aux) )
    Output written on test.dvi (1 page, 256 bytes).
    Transcript written on test.log.
    xdvi test.dvi

    Shows "Line1 Line2" on the page.


    Seems so simple I'll try. My first tex file.


    cer@Telcontar:~/samples/tex> xdvi test.dvi
    Warning: Missing charsets in String to FontSet conversion
    Warning: Unable to load any usable fontset
    Error: Aborting: no fontset found

    cer@Telcontar:~/samples/tex>


    cer@Telcontar:~/samples/tex> latex test.tex
    This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021/TeX Live
    for SUSE Linux) (preloaded format=latex)
    restricted \write18 enabled.
    entering extended mode
    (./test.tex
    LaTeX2e <2020-10-01> patch level 4
    L3 programming layer <2021-02-18>
    (/usr/share/texmf/tex/latex/base/article.cls
    Document Class: article 2020/04/10 v1.4m Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size11.clo)) (/usr/share/texmf/tex/latex/l3backend/l3backend-dvips.def)
    No file test.aux.
    [1] (./test.aux) )
    Output written on test.dvi (1 page, 256 bytes).
    Transcript written on test.log.
    cer@Telcontar:~/samples/tex> l
    total 20
    drwxr-xr-x 2 cer users 70 Jul 27 23:48 ./
    drwxr-xr-x 5 cer users 4096 Jul 27 23:47 ../
    -rw-r--r-- 1 cer users 32 Jul 27 23:48 test.aux
    -rw-r--r-- 1 cer users 256 Jul 27 23:48 test.dvi
    -rw-r--r-- 1 cer users 2489 Jul 27 23:48 test.log
    -rw-r--r-- 1 cer users 112 Jul 27 23:48 test.tex
    cer@Telcontar:~/samples/tex>


    cer@Telcontar:~/samples/tex> cat test.aux
    \relax
    \gdef \@abspage@last{1}
    cer@Telcontar:~/samples/tex>









    https://tex.stackexchange.com/questions/146909/what-does-mbox-do

    --
    Cheers, Carlos.

    --- Synchronet 3.21d-Linux NewsLink 1.2