1

I want to prepare view of LCD display that can have 8 lines of big text or 16 lines of small text. The sizes may be mixed so some lines will be with small font while some with big font at once.

Unfortunately strange things happen with distance between lines. What am I doing wrong?

Code

\documentclass{article}

\newcommand{\fontsmall}{\fontsize{5pt}{6pt}\selectfont}
\newcommand{\fontnormal}{\fontsize{10pt}{12pt}\selectfont}

\newsavebox{\mybox}
\newenvironment{display}{%
    \fontnormal%
    \begin{lrbox}{\mybox}%
    \begin{minipage}[][8\baselineskip][t]{15\baselineskip}%
}{%
    \end{minipage}%
    \end{lrbox}\fbox{\usebox{\mybox}}
}

\begin{document}

\begin{display}%
    linie 1\\
    linie 2\\
    linie 3\\
    linie 4\\
    linie 5\\
    linie 6\\
    linie 7\\
    linie 8
\end{display}%

\begin{display}%
    \fontsmall
    linie 1\\
    linie 2\\
    linie 3\\
    linie 4\\
    linie 5\\
    linie 6\\
    linie 7\\
    linie 8\\
    linie 9\\
    linie 10\\
    linie 11\\
    linie 12\\
    linie 13\\
    linie 14\\
    linie 15\\
    linie 16
\end{display}%

\begin{display}%
    \fontsmall
    \hfill \today\\
    ~\\
    \fontnormal
    some text \hfill some text \hfill some text\\
    some text \hfill some text \hfill some text\\
    some text \hfill some text \hfill some text\\
    \fontsmall
    linie 9\\
    linie 10\\
    linie 11\\
    linie 12\\
    linie 13\\
    linie 14\\
    linie 15\\
    linie 16
\end{display}%

\begin{display}%
    \fontsmall
    \hfill \today\\
    ~\\
    \fontnormal
    some text \hfill some text \hfill some text\\
    some text \hfill some text \hfill some text\\
    some text \hfill some text \hfill some text\\
    \fontsmall
    linie 9\\
    linie 10\\
    linie 11\\
    linie 12\\
    linie 13\\
    linie 14\\
    linie 15\\
    linie 16
    \fontnormal
\end{display}%

\begin{display}%
    \fontsmall
    \hfill \today\\
    \fontnormal
    some text \hfill some text \hfill some text\\
    some text \hfill some text \hfill some text\\
    some text \hfill some text \hfill some text\\
    \fontsmall
    linie 8\\
    linie 9\\
    linie 10\\
    linie 11\\
    linie 12\\
    linie 13\\
    linie 14\\
    linie 15\\
    linie 16
    \fontnormal
\end{display}%

\end{document}

Result

enter image description here

1

The problem is that you are misusing \\ for line breaks. Changes to the line spread will only take affect if the text in question is ended with a new paragraph. This can be done by leaving an empty line or use \par.

\documentclass{article}

\newcommand{\fontsmall}{\fontsize{5pt}{6pt}\selectfont}
\newcommand{\fontnormal}{\fontsize{10pt}{12pt}\selectfont}

\newsavebox{\mybox}
\newenvironment{display}{%
    \fontnormal%
    \begin{lrbox}{\mybox}%
    \begin{minipage}[][8\baselineskip][t]{15\baselineskip}%
}{%
    \end{minipage}%
    \end{lrbox}\fbox{\usebox{\mybox}}
}

\begin{document}

\begin{display}%
    linie 1

    linie 2

    linie 3

    linie 4

    linie 5

    linie 6

    linie 7

    linie 8
\end{display}%

\begin{display}%
    \fontsmall
    linie 1

    linie 2

    linie 3

    linie 4

    linie 5

    linie 6

    linie 7

    linie 8

    linie 9

    linie 10

    linie 11

    linie 12

    linie 13

    linie 14

    linie 15

    linie 16
\end{display}%

\begin{display}%
    \fontsmall
    \hfill \today

    ~

    \fontnormal
    some text \hfill some text \hfill some text

    some text \hfill some text \hfill some text

    some text \hfill some text \hfill some text

    \fontsmall
    linie 9

    linie 10

    linie 11

    linie 12

    linie 13

    linie 14

    linie 15

    linie 16
\end{display}%

\begin{display}%
    \fontsmall
    \hfill \today

    ~

    \fontnormal
    some text \hfill some text \hfill some text

    some text \hfill some text \hfill some text

    some text \hfill some text \hfill some text

    \fontsmall
    linie 9

    linie 10

    linie 11

    linie 12

    linie 13

    linie 14

    linie 15

    linie 16

    \fontnormal
\end{display}%

\begin{display}%
    \fontsmall
    \hfill \today

    \fontnormal
    some text \hfill some text \hfill some text

    some text \hfill some text \hfill some text

    some text \hfill some text \hfill some text

    \fontsmall
    linie 8

    linie 9

    linie 10

    linie 11

    linie 12

    linie 13

    linie 14

    linie 15

    linie 16

    \fontnormal
\end{display}%

\end{document}

enter image description here

  • Thank you very much. It works:) So simple. I prefer \par to avoid empty lines. – Simon Aug 23 '18 at 5:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.