Latex error: No line here to end (已解决)

在用到letax的时候有时候会出现错误:  

! LaTeX Error: There's no line here to end.

但是好像并不会影响pdf文件的编译效果。

出现这个错误的原因是使用了双斜杠 “\\” ,因为“\\”是一个换行命令,如果在使用的时候并不是在一个段落中,那么就会出现error。

例如:

\begin{description}
\item[Very long label] \\
  Text...
\end{description}

解决的办法就是强制中断当前的环境,从新开始一段,然后再用 “\\”:

\begin{description}
\item[Very long label] \leavevmode \\
  Text...
\end{description}

还有一种情况就是,在使用对齐命令: \center, \flushleft 或者 \flushright的时候:

\begin{center}
  First (heading) line\\
  \\
  body of the centerd text...
\end{center}

解决的方法很简单,可以直接在 “\\”之后带上一个可选的参数来指定要添加多少额外的空间:

\begin{center}
  First (heading) line\\[\baselineskip]
  body of the centerd text...
\end{center}

加上 \leavevmode 之后:

\begin{center}
  First (heading) line\\
  \leavevmode\\
  body of the centerd text...
\end{center}

参考:https://texfaq.org/FAQ-noline

 

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值