
Я хочу выровнять текст после некоторых слов. Я следовалэтот ответот @Torbjørn T. Но были сообщения об ошибках. Вот код:
\documentclass{report}
\usepackage{xcolor}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{\linewidth}{@{}lX@{}}
\textcolor{blue}{\textit{Name of the Experiment:} & Frequency Stability Study of a Power System blah blah blah}
\end{tabularx}
\end{document}
Сообщения об ошибках следующие:
line 9: Missing } inserted. \end{tabularx}
line 9: Extra }, or forgotten \endgroup. \end{tabularx}
line 9: Missing } inserted. \end{tabularx}
line 9: Extra }, or forgotten \endgroup. \end{tabularx}
line 9: Missing } inserted. \end{tabularx}
line 9: Extra }, or forgotten \endgroup. \end{tabularx}
line 9: Overfull \hbox (15.0pt too wide) in paragraph
Как можно решить эту проблему?
Я использую MiKTeX и PDFLaTeX.
решение1
По сути, ваша проблема в том, что вы не можете открыть текстовый цвет с помощью , \textcolor{blue}{
а затем начать следующую ячейку (с помощью &
). Вам нужно \textcolor{blue}{}
сначала закрыть, а затем начать следующую ячейку.
Либо вы хотели сделать с первым столбцомНазвание эксперимента:синим цветом, то вам нужно сделать вот так, и закрыть textcolor раньше:
\documentclass{report}
\usepackage{xcolor}
\usepackage{tabularx}
\begin{document}
\begingroup
\begin{tabularx}{\linewidth}{@{}lX@{}}
\textcolor{blue}{\textit{Name of the Experiment:}} & Frequency Stability Study of a Power System blah blah blah
\end{tabularx}
\end{document}
или вы хотели, чтобы весь текст в таблице был синим. Тогда вы помещаете таблицу в отдельную группу, как здесь:
\documentclass{report}
\usepackage{xcolor}
\usepackage{tabularx}
\begin{document}
\begingroup %%start wrapper group
\color{blue} %%assign textcolor
\begin{tabularx}{\linewidth}{@{}lX@{}}
\textit{Name of the Experiment:} & Frequency Stability Study of a Power System blah blah blah
\end{tabularx}
\endgroup%%end wrapper group
\end{document}
Взгляните наxcolor документация- вы также можете изменить цвет фона строк.