3

I'm trying to create a command to use when I need to translate the language or make examples to both languages. So far I have created a box around the text and two columns, one for each language.

\newcommand{\biling}[3]{%
    \begin{tcolorbox}[colback=blue!10!white,boxrule=0pt]
        \begin{center}%
            \begin{minipage}{#3cm}%
                \flushright%
                #1%
            \end{minipage}\hspace{.5cm}%
            \begin{minipage}{#3cm}%
                \flushleft%
                #2%
            \end{minipage}%
        \end{center}%
    \end{tcolorbox}%
}

It works in the two first boxes, but on the following chapter it's vertically misaligned as you can see in the image:

text misaligned vertically

The entire code is shown below:

\documentclass[12pt,a4paper]{book}

\usepackage{geometry}
\geometry{hmargin = 2cm}

\usepackage{fontspec}

\usepackage{polyglossia}
    \setdefaultlanguage{english}
    \disablehyphenation

\usepackage{mathastext}

\def\dtch{\( \dot{H} \)}
\def\dth{\( \dot{h} \)}
\def\dtcm{\( \dot{M} \)}
\def\dtm{\( \dot{m} \)}
\def\dtcy{\( \dot{Y} \)}
\def\dty{\( \dot{y} \)}

\usepackage{tcolorbox}
\usepackage{xcolor}

\newcommand{\biling}[3]{%
    \begin{tcolorbox}[colback=blue!10!white,boxrule=0pt]
        \begin{center}%
            \begin{minipage}{#3cm}%
                \flushright%
                #1%
            \end{minipage}\hspace{.5cm}%
            \begin{minipage}{#3cm}%
                \flushleft%
                #2%
            \end{minipage}%
        \end{center}%
    \end{tcolorbox}%
}

\title{Comprehensive Guide To Þerysh}

\begin{document}    
    Starting with the basics we have the conjugation for the verb to be.

    \biling{I am \\
        You are \\
        He is \\
        She is \\
        It is \\
        We are \\
        You are \\
        They are}%
    %
        {À ty \\
        \dtcy\ ty \\
        Þi ty \\
        Þa ty \\
        Iss ty \\
        Jos ty \\
        Wos ty \\
        Ðè ty}
        {2}

    The conjugation of the verb to be is the same for every person. It's important to notice that you singular form is a different word from a you plural form. Let's take a look in some examples of sentences:

    \biling{
        F \dty\ kn \textcolor{red}{bohw} ess, \dty\ ty ðróss! \\
        \dtch, \dtm\ cwaþ \textcolor{red}{ty} Bjorn. \\
        Iss ty h lajr \textcolor{red}{ganyst} \dty. \\
        À \textcolor{red}{valtur} portugsh. \\
        Þa \textcolor{red}{almie} þi. \\
        Ðè \textcolor{red}{svo} h kr. \\
        Jos \textcolor{red}{fint} mísk.}%
    %
        {If you can \textcolor{red}{read} this, you're awesome! \\
        Hi, my name \textcolor{red}{is} Bjorn. \\
        It's a pleasure to \textcolor{red}{meet} you. \\
        I \textcolor{red}{speak} portuguese. \\
        She \textcolor{red}{loves} he. \\
        They \textcolor{red}{see} a car. \\
        We \textcolor{red}{listen} to music.}
        {7}

    \chapter{The Present Tense}

    To form the \textsc{present tense} one simply conjugates the verb in its primal form to all persons to express the idea of an action or something that is currently going on or habitually performed, or a state that currently or generally exists. If one wants to say that someone eats, the verb to be conjugated is \textit{ctom}.

    \biling{À ctom \\
        \dtcy\ ctom \\
        Þi ctom \\
        Þa ctom \\
        Iss ctom \\
        Jos ctom \\
        Wos ctom \\
        Ðè ctom}%
    %
        {I eat \\
        You eat \\
        He eats \\
        She eats \\
        It eats \\
        We eat \\
        You eat \\
        They eat}%
    {3}

\end{document}

How to align it? Is there a package, or a command or an environment that already does that? I'm compiling it with LuaLaTeX.

  • 1
    To get alignment between columns, you should use a tabular. Otherwise they tend to drift apart due to larger-than-normal accented characters. – John Kormylo Feb 26 at 16:06
4

Use [t] alignment on your minipages.

\documentclass[12pt,a4paper]{book}

\usepackage{geometry}
\geometry{hmargin = 2cm}

\usepackage{fontspec}

\usepackage{polyglossia}
    \setdefaultlanguage{english}
    \disablehyphenation

\usepackage{mathastext}

\def\dtch{\( \dot{H} \)}
\def\dth{\( \dot{h} \)}
\def\dtcm{\( \dot{M} \)}
\def\dtm{\( \dot{m} \)}
\def\dtcy{\( \dot{Y} \)}
\def\dty{\( \dot{y} \)}

\usepackage{tcolorbox}
\usepackage{xcolor}

\newcommand{\biling}[3]{%
    \begin{tcolorbox}[colback=blue!10!white,boxrule=0pt]
        \begin{center}%
            \begin{minipage}[t]{#3cm}%
                \flushright%
                #1%
            \end{minipage}\hspace{.5cm}%
            \begin{minipage}[t]{#3cm}%
                \flushleft%
                #2%
            \end{minipage}%
        \end{center}%
    \end{tcolorbox}%
}

\title{Comprehensive Guide To Þerysh}

\begin{document}    
    Starting with the basics we have the conjugation for the verb to be.

    \biling{I am \\
        You are \\
        He is \\
        She is \\
        It is \\
        We are \\
        You are \\
        They are}%
    %
        {À ty \\
        \dtcy\ ty \\
        Þi ty \\
        Þa ty \\
        Iss ty \\
        Jos ty \\
        Wos ty \\
        Ðè ty}
        {2}

    The conjugation of the verb to be is the same for every person. It's important to notice that you singular form is a different word from a you plural form. Let's take a look in some examples of sentences:

    \biling{
        F \dty\ kn \textcolor{red}{bohw} ess, \dty\ ty ðróss! \\
        \dtch, \dtm\ cwaþ \textcolor{red}{ty} Bjorn. \\
        Iss ty h lajr \textcolor{red}{ganyst} \dty. \\
        À \textcolor{red}{valtur} portugsh. \\
        Þa \textcolor{red}{almie} þi. \\
        Ðè \textcolor{red}{svo} h kr. \\
        Jos \textcolor{red}{fint} mísk.}%
    %
        {If you can \textcolor{red}{read} this, you're awesome! \\
        Hi, my name \textcolor{red}{is} Bjorn. \\
        It's a pleasure to \textcolor{red}{meet} you. \\
        I \textcolor{red}{speak} portuguese. \\
        She \textcolor{red}{loves} he. \\
        They \textcolor{red}{see} a car. \\
        We \textcolor{red}{listen} to music.}
        {7}

    \chapter{The Present Tense}

    To form the \textsc{present tense} one simply conjugates the verb in its primal form to all persons to express the idea of an action or something that is currently going on or habitually performed, or a state that currently or generally exists. If one wants to say that someone eats, the verb to be conjugated is \textit{ctom}.

    \biling{À ctom \\
        \dtcy\ ctom \\
        Þi ctom \\
        Þa ctom \\
        Iss ctom \\
        Jos ctom \\
        Wos ctom \\
        Ðè ctom}%
    %
        {I eat \\
        You eat \\
        He eats \\
        She eats \\
        It eats \\
        We eat \\
        You eat \\
        They eat}%
    {3}

\end{document}

enter image description here

With the default (center) alignment, you get the undesired text shift:

enter image description here

1

If you use the the tcolorbox package may be you don't need the minipages and instead of defining the \biling command with three arguments define a \newtcolorbox{biling}{...}

\documentclass[12pt,a4paper]{book}

\usepackage{geometry}
\geometry{hmargin = 2cm}

\usepackage{fontspec}

\usepackage{polyglossia}
    \setdefaultlanguage{english}
    \disablehyphenation

\usepackage{mathastext}

\def\dtch{\( \dot{H} \)}
\def\dth{\( \dot{h} \)}
\def\dtcm{\( \dot{M} \)}
\def\dtm{\( \dot{m} \)}
\def\dtcy{\( \dot{Y} \)}
\def\dty{\( \dot{y} \)}

\usepackage{tcolorbox}
%\usepackage{xcolor}

\newtcolorbox{bilingbox}{colback=blue!10!white,
                          frame empty,
                          segmentation empty,
                          halign=flush right,
                          sidebyside,
                          sidebyside gap=5mm,
                          sidebyside align=top
                          }

% \newcommand{\biling}[3]{%
%     \begin{tcolorbox}[colback=blue!10!white,boxrule=0pt]
%         \begin{center}%
%             \begin{minipage}{#3cm}%
%                 \flushright%
%                 #1%
%             \end{minipage}\hspace{.5cm}%
%             \begin{minipage}{#3cm}%
%                 \flushleft%
%                 #2%
%             \end{minipage}%
%         \end{center}%
%     \end{tcolorbox}%
% }

\title{Comprehensive Guide To Þerysh}

\begin{document}    
    Starting with the basics we have the conjugation for the verb to be.

    \begin{bilingbox}
    I am \\
        You are \\
        He is \\
        She is \\
        It is \\
        We are \\
        You are \\
        They are
        \tcblower
        À ty \\
        \dtcy\ ty \\
        Þi ty \\
        Þa ty \\
        Iss ty \\
        Jos ty \\
        Wos ty \\
        Ðè ty

    \end{bilingbox}

    % \biling{I am \\
    %     You are \\
    %     He is \\
    %     She is \\
    %     It is \\
    %     We are \\
    %     You are \\
    %     They are}%
    % %
    %     {À ty \\
    %     \dtcy\ ty \\
    %     Þi ty \\
    %     Þa ty \\
    %     Iss ty \\
    %     Jos ty \\
    %     Wos ty \\
    %     Ðè ty}
    %     {2}

    The conjugation of the verb to be is the same for every person. It's important to notice that you singular form is a different word from a you plural form. Let's take a look in some examples of sentences:

    \begin{bilingbox}
     F \dty\ kn \textcolor{red}{bohw} ess, \dty\ ty ðróss! \\
        \dtch, \dtm\ cwaþ \textcolor{red}{ty} Bjorn. \\
        Iss ty h lajr \textcolor{red}{ganyst} \dty. \\
        À \textcolor{red}{valtur} portugsh. \\
        Þa \textcolor{red}{almie} þi. \\
        Ðè \textcolor{red}{svo} h kr. \\
        Jos \textcolor{red}{fint} mísk.

        \tcblower
    If you can \textcolor{red}{read} this, you're awesome! \\
        Hi, my name \textcolor{red}{is} Bjorn. \\
        It's a pleasure to \textcolor{red}{meet} you. \\
        I \textcolor{red}{speak} portuguese. \\
        She \textcolor{red}{loves} he. \\
        They \textcolor{red}{see} a car. \\
        We \textcolor{red}{listen} to music.
    \end{bilingbox}

    % \biling{
    %     F \dty\ kn \textcolor{red}{bohw} ess, \dty\ ty ðróss! \\
    %     \dtch, \dtm\ cwaþ \textcolor{red}{ty} Bjorn. \\
    %     Iss ty h lajr \textcolor{red}{ganyst} \dty. \\
    %     À \textcolor{red}{valtur} portugsh. \\
    %     Þa \textcolor{red}{almie} þi. \\
    %     Ðè \textcolor{red}{svo} h kr. \\
    %     Jos \textcolor{red}{fint} mísk.}%
    % %
    %     {If you can \textcolor{red}{read} this, you're awesome! \\
    %     Hi, my name \textcolor{red}{is} Bjorn. \\
    %     It's a pleasure to \textcolor{red}{meet} you. \\
    %     I \textcolor{red}{speak} portuguese. \\
    %     She \textcolor{red}{loves} he. \\
    %     They \textcolor{red}{see} a car. \\
    %     We \textcolor{red}{listen} to music.}
    %     {7}

    \chapter{The Present Tense}

    To form the \textsc{present tense} one simply conjugates the verb in its primal form to all persons to express the idea of an action or something that is currently going on or habitually performed, or a state that currently or generally exists. If one wants to say that someone eats, the verb to be conjugated is \textit{ctom}.

    \begin{bilingbox}
    À ctom \\
        \dtcy\ ctom \\
        Þi ctom \\
        Þa ctom \\
        Iss ctom \\
        Jos ctom \\
        Wos ctom \\
        Ðè ctom

        \tcblower
        I eat \\
        You eat \\
        He eats \\
        She eats \\
        It eats \\
        We eat \\
        You eat \\
        They eat

    \end{bilingbox}

    % \biling{À ctom \\
    %     \dtcy\ ctom \\
    %     Þi ctom \\
    %     Þa ctom \\
    %     Iss ctom \\
    %     Jos ctom \\
    %     Wos ctom \\
    %     Ðè ctom}%
    % %
    %     {I eat \\
    %     You eat \\
    %     He eats \\
    %     She eats \\
    %     It eats \\
    %     We eat \\
    %     You eat \\
    %     They eat}%
    % {3}

\end{document}

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.