几个目录

几个目录

如果包含外部 tex 文件(通过 \input),该如何编辑代码?外部文件应该有自己独立的目录。

    \documentclass[a4paper]{article}
    % renew \contentsline for toc to include hypertarget
    \let\oldcontentsline\contentsline%
    \renewcommand\contentsline[4]{%
    \hypertarget{toc#4}{}%
    \oldcontentsline{#1}{#2}{#3}{#4}}

    % renew \section to link to the toc
    \titleformat{\section}
    {\normalfont\Large\bf}
    {{\thesection} \hyperlink{tocsection.\thesection}{#1}}
    {1pc}
    {}

    % renew \subsection to link to the toc
    \titleformat{\subsection}
    {\normalfont\bf}
    {{\thesection} \hyperlink{tocsubsection.                    \thesubsection}{#1}}
    {1pc}{}

    % renew \subsubsection to link to the toc
    \titleformat{\subsubsection}
    {\normalfont\bf}
    {{\thesection} \hyperlink{tocsubsubsection.        \thesubsubsection}{#1}}
    {1pc}{}

    \begin{document}
    \tableofcontents


    \section{abcd}


    \end{document}

感谢帮助!


@David Carliste 以下是代码:

%main.text
%\documentclass{article}
%\documentclass[11.5pt]{scrartcl}
\documentclass[a4paper]{article}
\usepackage{lipsum} % sample text
\usepackage[explicit]{titlesec} % to change headings
\usepackage{hyperref}
\usepackage[latin1]{inputenc}
\usepackage{xcolor}
\usepackage{pdflscape}
%\usepackage{lscape}
%\usepackage[pdftex]{insdljs}
\usepackage[margin=3cm]{geometry}
\usepackage{hyperref}
\usepackage{multirow,tabularx}
\usepackage[normalem]{ulem}
%\usepackage[pdftex]{insdljs}
\usepackage{graphicx}
\usepackage{color}
\usepackage{tikz}
\usetikzlibrary{through}
\usepackage{tabu}
\usepackage{xcolor}
\usepackage{pdflscape}
%\usepackage{lscape}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
%\usepackage[ansinew]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{relsize}
\usepackage{textcomp}
\usepackage{tikz,xcolor,mwe}
\usepackage{makeidx}
\makeindex
\usepackage{imakeidx}
\makeindex[columns=3, title=Alphabetical Index, 
options= -s example_style.ist]
\usepackage{tikz}
\usepackage{amssymb}
\usepackage{xpatch}
\usepackage{mwe}
\usepackage{shorttoc}
\setcounter{tocdepth}{3}

\newcommand{\wye}{\mathbin{\tikz[x=1ex,y=1ex]{\draw[line width=.1ex] (0,0)--(30:1)--++(-30:1) (30:1)--++(0,1);}}}

% renew \contentsline for toc to include hypertarget
\let\oldcontentsline\contentsline%
\renewcommand\contentsline[4]{%
    \hypertarget{toc#4}{}%
    \oldcontentsline{#1}{#2}{#3}{#4}}

% renew \section to link to the toc
\titleformat{\section}
{\normalfont\Large\bf}
{{\thesection} \hyperlink{tocsection.\thesection}{#1}}
{1pc}
{}

% renew \subsection to link to the toc
\titleformat{\subsection}
{\normalfont\bf}
{{\thesection} \hyperlink{tocsubsection.\thesubsection}{#1}}
{1pc}
{}

% renew \subsubsection to link to the toc
\titleformat{\subsubsection}
{\normalfont\bf}
{{\thesection} \hyperlink{tocsubsubsection.\thesubsubsection}{#1}}
{1pc}
{}

\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,      
    urlcolor=cyan,
    pdftitle={Overleaf Example},
    pdfpagemode=FullScreen,
}

\definecolor{MyCyan}{RGB}{0,255,255}
\definecolor{MyRed}{RGB}{255,0,0}
\definecolor{MyGreen}{RGB}{0,255,0}
\definecolor{MyBlue}{RGB}{0,0,255}
\definecolor{MyOrangeBrown}{RGB}{255,127,0}

\definecolor{LB}{RGB}{0,255,255}
\definecolor{BV}{RGB}{0,0,0}
\definecolor{O}{RGB}{0,0,255}
\definecolor{A}{RGB}{0,0,255}
\definecolor{Z}{RGB}{0,255,0}
\definecolor{LK}{RGB}{255,87,255}

\begin{document}

\newgeometry{
        left=0.2cm,
        right=0.2cm,
        top=0.2cm,
        bottom=0.2cm,
        bindingoffset=2mm
    }
    
    \newgeometry{
        left=1cm,
        right=1cm,
        top=1cm,
        bottom=1cm,
        bindingoffset=2mm
    }
    
    \UseRawInputEncoding
    
    \begin{titlepage}
        \author{Marc} 
        \title{\"Ubersicht} 
        %\subtitle{eigene Pl\"ane}
        \date{} 
        \maketitle
    \end{titlepage}
    
    
    \tableofcontents
    \clearpage
    
    \newpage

    \section{Geb\"aude}

    \subsection{Gesamt}
    \input{95283.tex}
    \subsection{Gesamt2}

    \section{Geb\"aude2}

\end{document}

相关内容