[LaTeX] 여러 줄 주석처리

2023. 3. 16. 10:03·기타/논문작성 Writing

LaTeX는 주석처리를 하려면 주석처리하고 싶은 줄을 드래그하고 CTRL+/ 단축키를 통해 %를 추가하여 주석으로 만들 수 있다.

그런데 긴 줄의 코드를 주석처리하고 싶으면 이런 방식이 어려울 것이다. 이 글에서는 여러 줄을 한 보이게 하는 방법에 대해 다룬다.

 

1. 패키지 comment 또는 verbatim을 통해 comment 블록 생성

 

내가 찾아본 방법으로 가장 간단한 것은

 

\usepackage{verbatim}

\begin{comment}
% 주석처리할 내용
\end{comment}

 

다음과 같이 주석내용을 comment 블럭으로 감싸주는 것이다.

package verbatim도 필요하니 같이 넣어준다.

그런데 verbatim의 경우 문제가 발생할 수도 있다고 한다. 따라서 \usepackage{comment}를 사용해도 괜찮다고 한다.

 

더 advanced하게 사용하려면

\documentclass{article}
\usepackage{comment}

% uncomment to include stuff in standard comment-environment
%\includecomment{comment}

% define a mysection env which content is excluded
\excludecomment{mysection}

\begin{document}
    This text will be displayed
\begin{comment}
    This text will only be displayed, if \includecomment{comment} was given
\end{comment}
\begin{mysection}
    This text will only be displayed, if \includecomment{mysection} was given
\end{mysection}
\end{document}

위와 같이 comment나 mysection을 document이전에 배제할지, 포함할지를 결정하면 된다.

 

 

2. TeX 문법의 \iffalse 사용

\iffalse
I don't want this to happen
\fi

\iffalse로 처리해뒀다가 보이게 하고 싶으면 \iftrue로 바꿔주면 된다고 한다.

 

 


참고자료

 

https://tex.stackexchange.com/questions/87303/multi-line-block-comments-in-latex

https://tex.stackexchange.com/questions/17816/commenting-out-large-sections

저작자표시 비영리 변경금지 (새창열림)

'기타 > 논문작성 Writing' 카테고리의 다른 글

[Zotero] citation key 고정  (0) 2023.04.24
[논문작성] Biography (예시)  (0) 2023.04.05
[LaTeX] Table 만들기  (1) 2023.03.14
[논문작성] Zotero에서 bibtex 내보낼 때 제목형식 바꾸는 방법  (0) 2023.03.07
[서지관리프로그램] ENDNOTE/Mendeley/Zotero  (3) 2023.03.06
'기타/논문작성 Writing' 카테고리의 다른 글
  • [Zotero] citation key 고정
  • [논문작성] Biography (예시)
  • [LaTeX] Table 만들기
  • [논문작성] Zotero에서 bibtex 내보낼 때 제목형식 바꾸는 방법
보통의공대생
보통의공대생
수학,프로그래밍,기계항공우주 등 공부하는 기록들을 남깁니다.
  • 보통의공대생
    뛰는 놈 위에 나는 공대생
    보통의공대생
  • 전체
    오늘
    어제
    • 분류 전체보기 (460) N
      • 공지 (1)
      • 영어 공부 English Study (40)
        • 텝스 TEPS (7)
        • 글 Article (21)
        • 영상 Video (10)
      • 연구 Research (99)
        • 최적화 Optimization (3)
        • 데이터과학 Data Science (7)
        • 인공지능 Artificial Intelligent (40)
        • 제어 Control (45)
      • 프로그래밍 Programming (103)
        • 매트랩 MATLAB (25)
        • 파이썬 Python (33)
        • 줄리아 Julia (2)
        • C++ (3)
        • 리눅스 우분투 Ubuntu (6)
      • 항공우주 Aeronautical engineeri.. (21)
        • 항법 Navigation (0)
        • 유도 Guidance (0)
      • 기계공학 Mechanical engineering (13)
        • 열역학 Thermodynamics (0)
        • 고체역학 Statics & Solid mechan.. (10)
        • 동역학 Dynamics (1)
        • 유체역학 Fluid Dynamics (0)
      • 수학 Mathematics (34)
        • 선형대수학 Linear Algebra (18)
        • 미분방정식 Differential Equation (3)
        • 확률및통계 Probability & Sta.. (2)
        • 미적분학 Calculus (1)
        • 복소해석학 Complex Analysis (5)
        • 실해석학 Real Analysis (0)
      • 수치해석 Numerical Analysis (21)
      • 확률 및 랜덤프로세스 Random process (2)
      • 추론 & 추정 이론 Estimation (3)
      • 기타 (26)
        • 설계 프로젝트 System Design (8)
        • 논문작성 Writing (55)
        • 세미나 Seminar (2)
        • 생산성 Productivity (3)
      • 유학 생활 Daily (7) N
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    teps
    논문작성
    ChatGPT
    Numerical Analysis
    생산성
    Statics
    우분투
    인공지능
    MATLAB
    pytorch
    논문작성법
    JAX
    Zotero
    IEEE
    obsidian
    텝스
    텝스공부
    Python
    서버
    옵시디언
    Julia
    에러기록
    WOX
    matplotlib
    Dear abby
    딥러닝
    수치해석
    고체역학
    LaTeX
    Linear algebra
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
보통의공대생
[LaTeX] 여러 줄 주석처리
상단으로

티스토리툴바