2010-01-05 96 views
4

,我有以下Latex环境乳胶环境:建立类似公式环境

\newcounter{txtctr}[section] \setcounter{txtctr}{0} 
\newenvironment{textex}{% This is the begin code 
    \refstepcounter{txtctr} \vspace{0.2cm} {\noindent 
    (T.\arabic{chapter}.\arabic{section}.\arabic{txtctr}): 
    }\footnotesize\vspace{-0.2cm}}{\normalsize} 

,但我想有柜台的权利,并在环境中的文字中间。喜欢的东西:

Canis per flumen carnem dum ferret natans 
aliamque praedam ab alio      (T1.1.1) 
Canis per flumen carnem dum ferret natans 

我想这可能需要一个minipage做了什么?顺便说一下,环境必须对verbatim环境友好。

有些Latex向导可以帮我吗?

谢谢。

回答

2

我怀疑有一个包可以自动执行此操作(即编号的代码示例),但现在没有什么可以想到的。

您正在使用的哪个逐字包指示您要如何执行此操作,但是像这样垂直居中框的常规技巧是按照您的建议使用小型文件。只需适当地设置它们的宽度,并没有太多的东西。

 
\begin{minipage}[c]{0.9\linewidth} 
    % your environment goes here 
\end{minipage}\hfill 
\begin{minipage}[c]{0.09\linewidth} 
(T.\arabic{chapter}.\arabic{section}.\arabic{txtctr})% 
\end{minipage} 
1

尝试和调整了这一点:

\documentclass{article} 

\newcounter{txtctr}%Defines couter 
\def\thetxtctr{\thesection-\arabic{txtctr}}%Typesets counter 

\newenvironment{textex}{% This is the begin code 
\begin{minipage}[c]{.8\textwidth}% 
}% 
{% This is ending code 
\end{minipage} 
\begin{minipage}[c]{.2\textwidth} 
\flushright\thetxtctr 
\end{minipage} 
} 
\begin{document} 

\section{hhh} 
\begin{textex} 
\begin{verbatim} 
Canis per flumen carnem dum ferret natans 
aliamque praedam ab alio 
Canis per flumen carnem dum ferret natans 
\end{verbatim} 
\end{textex} 
\end{document} 

answer of Alexey Malistov