创建翻译句子的环境

创建翻译句子的环境

我正在尝试创建一个命令,用于需要翻译语言或制作两种语言的示例时使用。到目前为止,我已经在文本周围创建了一个框和两列,每种语言一列。

\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}%
}

它在前两个框中起作用,但在下一章中它垂直错位,正如您在图像中看到的那样:

文本垂直错位

整个代码如下所示:

\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}

如何对齐?是否有一个包、命令或环境可以做到这一点?我正在使用 LuaLaTeX 进行编译。

答案1

在你的 s 上使用[t]对齐minipage

\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}

在此处输入图片描述

使用默认(居中)对齐方式,您会看到不想要的文本偏移:

在此处输入图片描述

答案2

如果你使用包tcolorbox可能你不需要minipages 并且不是定义\biling带有三个参数的命令而是定义一个\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}

相关内容